Registers a frame to monitor for events.
success = frame:RegisterEvent(event)
- string - The name of the event to register the object as monitoring.
- boolean - True when frame is successfully registered to a new event; otherwise false, such as if the frame was already registered to this event.
- Widgets are usually notified of an event in order they were registered, but Frame:UnregisterEvent tends to move the last-registered widget up to fill the gap. Consequently, this behaviour should not be relied upon.
-- Create a frame local f = CreateFrame("Frame") -- Register to monitor events f:RegisterEvent("CHAT_MSG_YELL") f:RegisterEvent("CHAT_MSG_SAY") -- Handle the events as they happen f:SetScript("OnEvent", function(self, event, ...) if (event == "CHAT_MSG_YELL") then print("Argh, stop with the yelling!") elseif (event == "CHAT_MSG_SAY") then print("Thanks, that was much softer.") end end)
- Patch 8.0.1 / API (2018-07-17): Registering a non-existing event now raises an error instead of returning nil.