Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!

API Frame RegisterEvent

From Wowpedia
Jump to: navigation, search

Registers which events the object would like to monitor.

success = frame:RegisterEvent("event")

Arguments

event 
string - The name of the event to register the object as monitoring.

Returns

success 
boolean - Returns true if the event was successfully registered, false if (already) registered.

Example

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)

Notes

  • Attempting to register for a non-existing event is silently ignored; Frame:IsEventRegistered("event") returns nil in such a case.

Battle for Azeroth Patch 8.0.1 (2018-07-17): Since patch 8.0.1 registering a non-existing event will raise an error.

  • 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.

See also