WoW:USERAPI Frame UnregisterEvents: Difference between revisions
Jump to navigation
Jump to search
m (New page: {{userfunc}} __NOTOC__ Add this method to your frame to register multiple events. == Code == local function UnregisterEvents(self, ...) for _,event in pairs({...}) do self...) |
m (Move page script moved page USERAPI Frame UnregisterEvents to USERAPI Frame UnregisterEvents without leaving a redirect) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{usermethod}} | ||
Add this method to your frame to register multiple events. | Add this method to your frame to register multiple events. | ||
== Code == | == Code == | ||
local function UnregisterEvents(self, ...) | local function UnregisterEvents(self, ...) | ||
for i=1,select('#', ...) do | |||
self:UnregisterEvent(select(i, ...)) | |||
end | |||
end | end | ||
Line 18: | Line 16: | ||
frame:UnregisterEvents('VARIABLES_LOADED', 'ADDON_LOADED', 'MERCHANT_SHOW') | frame:UnregisterEvents('VARIABLES_LOADED', 'ADDON_LOADED', 'MERCHANT_SHOW') | ||
Or unregister events for a frame without | Or unregister events for a frame without attaching UnregisterEvents to the frame: | ||
local frame = YourEventFrame | local frame = YourEventFrame | ||
-- Tell the API to stop listen for 'VARIABLES_LOADED', 'ADDON_LOADED', and 'MERCHANT_SHOW' | -- Tell the API to stop listen for 'VARIABLES_LOADED', 'ADDON_LOADED', and 'MERCHANT_SHOW' | ||
UnregisterEvents(frame, 'VARIABLES_LOADED', 'ADDON_LOADED', 'MERCHANT_SHOW') | UnregisterEvents(frame, 'VARIABLES_LOADED', 'ADDON_LOADED', 'MERCHANT_SHOW') |
Latest revision as of 04:49, 15 August 2023
This page documents a <i>user-defined function</i> that you can copy and paste into your addon. Replace <PREFIX> with your AddOn's prefix to avoid conflicts between different versions of these functions.
← User defined functions < Frame:UnregisterEvents
Add this method to your frame to register multiple events.
Code[edit]
local function UnregisterEvents(self, ...) for i=1,select('#', ...) do self:UnregisterEvent(select(i, ...)) end end
Example[edit]
local frame = YourEventFrame frame.UnregisterEvents = UnregisterEvents -- Tell the API to stop listen for 'VARIABLES_LOADED', 'ADDON_LOADED', and 'MERCHANT_SHOW' frame:UnregisterEvents('VARIABLES_LOADED', 'ADDON_LOADED', 'MERCHANT_SHOW')
Or unregister events for a frame without attaching UnregisterEvents to the frame:
local frame = YourEventFrame -- Tell the API to stop listen for 'VARIABLES_LOADED', 'ADDON_LOADED', and 'MERCHANT_SHOW' UnregisterEvents(frame, 'VARIABLES_LOADED', 'ADDON_LOADED', 'MERCHANT_SHOW')