API Frame RegisterEvent
Registers which events the object would like to monitor.
success = frame:RegisterEvent("event")
- string - The name of the event to register the object as monitoring.
- boolean - Returns true if the event was successfully registered, false if (already) registered.
The snippet below creates a frame, registers it for the CHAT_MSG_YELL event, and sets an OnEvent handler that would print a message whenever that event fires -- whenever you hear someone /yell.
local frame = CreateFrame("Frame") frame:RegisterEvent("CHAT_MSG_YELL") frame:SetScript("OnEvent", function(self, event, ...) print("Argh, stop with the yelling!") end)
- Attempting to register for a non-existing event is silently ignored; Frame:IsEventRegistered("event") returns
nilin such a case.
- Widgets are notified of an event in order of event registration: the last widget to register for an event will be the last one to receive it.