49
edits
mNo edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{{ | {{eventapi}} | ||
Events are messages sent by the WoW client to UI code (OnEvent script handlers of Frame derivatives), mostly in reaction to things occurring in the game world. To process events, an addon needs to create an event handler and register it for the events it wishes to receive. | Events are messages sent by the WoW client to UI code (OnEvent script handlers of Frame derivatives), mostly in reaction to things occurring in the game world. To process events, an addon needs to create an event handler and register it for the events it wishes to receive. | ||
| Line 5: | Line 5: | ||
Events are sent to Frame-derived [[Widget API|widgets]]; an add-on needs to create a frame if it does not already own one that can be used for the purpose of handling events. Frames may be created in Lua using the [[API_CreateFrame|CreateFrame]] function; or constructed in XML (using the <Frame> tag). | Events are sent to Frame-derived [[Widget API|widgets]]; an add-on needs to create a frame if it does not already own one that can be used for the purpose of handling events. Frames may be created in Lua using the [[API_CreateFrame|CreateFrame]] function; or constructed in XML (using the <Frame> tag). | ||
Once a frame has been created, its OnEvent handler must be set to a function that would handle the event on behalf of the addon. The OnEvent script handler may be set using the Lua frame:[[API_Frame_SetScript|SetScript]]() function; or constructed in XML (using <Scripts><OnEvent>function body</OnEvent></Scripts>). The OnEvent handler function receives at least two arguments: | Once a frame has been created, its OnEvent handler must be set to a function that would handle the event on behalf of the addon. The OnEvent script handler may be set using the Lua frame:[[API_Frame_SetScript|SetScript]]() function; or constructed in XML (using <Scripts><OnEvent>function body</OnEvent></Scripts>). The OnEvent handler function receives at least two arguments: | ||
# self, a reference to the frame to which the script handler belongs | # self, a reference to the frame to which the script handler belongs | ||
# event, the name of the event being fired | # event, the name of the event being fired | ||