Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:WindowRegisterCoreEventHandler

From RoR Wiki

UI Lua API · Window functions
Version: WAR 1.4.8

Sets the Lua function that a window calls for one of its own (core) events, such as a mouse click.

WindowRegisterCoreEventHandler(windowName, eventName, functionName)

Arguments

windowName
string – Name of the window.
eventName
string – Name of the core event, for example "OnLButtonUp". See the list below.
functionName
string – Name of the Lua function to call, as a dotted path such as "MyAddon.OnClick".

Returns

Nothing.

Details

  • These are the core event names in the client's event table:
    • OnInitialize, OnInitializeCustomSettings, OnShutdown, OnUpdate
    • OnLButtonDown, OnLButtonUp, OnLButtonDblClk, OnRButtonDown, OnRButtonUp, OnRButtonDblClk, OnMButtonDown, OnMButtonUp, OnMButtonDblClk
    • OnMouseOver, OnMouseOverEnd, OnMouseDrag, OnMouseWheel
    • OnKeyEnter, OnKeyTab, OnKeyEscape, OnRawDeviceInput, OnGamepadInput
    • OnShown, OnHidden, OnSizeUpdated, OnSetMoving
    • OnHyperLinkLButtonDown, OnHyperLinkLButtonUp, OnHyperLinkRButtonDown, OnHyperLinkRButtonUp, OnHyperLinkMButtonDown, OnHyperLinkMButtonUp, OnHyperLinkMouseOver, OnHyperLinkMouseOverEnd
  • The call fails silently (no error) when:
    • eventName is not a known core event name,
    • eventName or functionName is empty, or
    • the window already has a handler for that event. The old handler stays. Remove it first with WindowUnregisterCoreEventHandler.
  • Window XML sets the same handlers with <EventHandler event="OnLButtonUp" function="..." />. This function adds one at run time, for example to a window created from a template.
  • For game events (SystemData.Events.*) use WindowRegisterEventHandler instead.

Errors

  • Error in function call 'WindowRegisterCoreEventHandler': Window %s does not exist

Example

Making a context menu item react to clicks and mouse-over, from ea_chatwindow/source/chatwindow.lua:

CreateWindowFromTemplate ("ChatWindowContextShowTimestamp", "ChatContextMenuItemCheckBox", "Root")
LabelSetText( "ChatWindowContextShowTimestampCheckBoxLabel", GetChatString( StringTables.Chat.LABEL_CHAT_TAB_TIMESTAMP ) )
WindowRegisterCoreEventHandler("ChatWindowContextShowTimestamp", "OnLButtonUp", "EA_ChatWindow.ToggleTimestamp")
WindowRegisterCoreEventHandler("ChatWindowContextShowTimestamp", "OnMouseOver", "EA_Window_ContextMenu.OnMouseOverDefaultMenuItem")

See also