This is a small addon that allows you to write event handlers in a GUI in-game. Useful if you want to look up the event arguments, check some state or even save stuff to saved variables.
- you can enable/disable events without losing your handler code
- a default handler displaying all event arguments is provided
- you can write stuff to the addon's SavedVariables from within your handler
- you can register further events and add additional event handlers from within your handlers (use at your own risk)
Type /handleit
or /hit
in the chat to open the options. Click "New event" or select an existing one. Edit to your
liking.
Anytime you change something, the event will be automatically disabled. Re-enable when you are done.
In your handler you get the following arguments through ...
, the same way you get the addon's name and namespace in
addons, meaning you can name those whatever you like:
- self - the frame the addon uses for event registration (Frame)
- db - a reference to the addon's global SavedVariables. Use this to save your state if needed (table)
- event - the name of the triggered event (string)
- ... - any further event arguments
Calling other event handlers is done by self[event](...)
where self
is the addon's frame, event
is the event name
and ...
preserves the argument order as above.
The API, in its current state, is not meant to replace or alter the GUI. This is what the GUI uses to (un)register events and is exposed to you in case you find it useful. The state of the GUI is saved to the addon's SavedVariables.
-
:AddEvent(data)
- used to add a new event, or add further callbacks to its handler. Adding an event means registering it and attaching the supplied callbacks to make up a handler.
data
is a simple associative array as follows:- event - the name of the event you'd like to register (string)
- unit1 - the first event unit (string or nil)
- unit2 - the second event unit (string or nil)
- handler - the callback(s) you want to use as the event handler (string or function or a table thereof)
NOTE: If you call
:AddEvent
for an already added event, it will add the new callbacks instead of rewriting the old ones.
If eitherunit1
orunit2
are non-nils,RegisterUnitEvent
will be used for event registration potentially overwriting event units from previous calls. -
:RemoveEvent(data)
- used to remove an event, wheredata
is structured as described above. Actually onlydata.event
plays a role here. Removing an event means unregistering it und deleting the associated handler.
The GUI is limited to one handler per event. So if you added another handler from code and then edit the event in the GUI, the handler you added will be detached automatically without notice.
The GUI does not list events and handlers you added from code.
You can file bug reports and issues on the project's page at GitHub.