Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:WindowRegisterEventHandler

From RoR Wiki

UI Lua API · Window functions
Version: WAR 1.4.8

Makes a window call a Lua function whenever a game event is broadcast.

WindowRegisterEventHandler(windowName, eventId, functionName)

Arguments

windowName
string – Name of the window that owns the handler.
eventId
number – The event, usually a SystemData.Events.* value.
functionName
string – Name of the Lua function to call, as a dotted path such as "MyAddon.OnEvent".

Returns

Nothing.

Details

  • A window can have one handler per event. Registering a second handler for the same event raises the already has an event handler error, which names the existing handler. Remove the old one first with WindowUnregisterEventHandler.
  • eventId is truncated to a whole number. It is not checked against the known events.
  • The handler belongs to the window. Many stock windows register on "Root" for events that do not belong to a particular window.
  • For a window's own events, such as mouse clicks, use WindowRegisterCoreEventHandler.
  • easystem_dialogmanager/source/dialogs.lua calls WindowRegisterEventHandler( "GROUP_INVITE_ID", "GroupInviteCallback" ). That call passes only two arguments, with a string where the event number belongs, so it does not register anything.

Errors

  • Error in function call 'WindowRegisterEventHandler': Window %s does not exist
  • Error in function call 'WindowRegisterEventHandler': Window %s already has an event handler (%s) for event %d.

Example

From easystem_windowutils/source/windowutils.lua:

WindowRegisterEventHandler( "Root", SystemData.Events.ESCAPE_KEY_PROCESSED, "WindowUtils.EscapeKeyProcessed")

From ea_abilitieswindow/source/abilitieswindow.lua:

WindowRegisterEventHandler( "AbilitiesWindow", SystemData.Events.PLAYER_ABILITIES_LIST_UPDATED, "AbilitiesWindow.UpdateIfNotLoading")

See also