WoW:API Frame SetScript: Difference between revisions
Jump to navigation
Jump to search
(Update link to additional widget handlers) |
(Factual correction) |
||
Line 11: | Line 11: | ||
:;handler : String - The handler to attach func to (OnShow, OnEvent, [[Widget_handlers|et al]]) | :;handler : String - The handler to attach func to (OnShow, OnEvent, [[Widget_handlers|et al]]) | ||
:;func : Function - The function to call. <tt>nil</tt> to remove the handler. <tt>func</tt> is called with arguments <tt>(frame | :;func : Function - The function to call. <tt>nil</tt> to remove the handler. <tt>func</tt> is called with arguments <tt>(frame, arg1, arg2, ...)</tt> (<tt>event</tt> being <tt>arg1</tt> for OnEvent handlers) | ||
== Example == | == Example == | ||
for i = 1, 4 do | for i = 1, 4 do | ||
local frame = getglobal("PartyMemberFrame"..i) | local frame = getglobal("PartyMemberFrame"..i) | ||
frame:SetScript("OnShow", | frame:SetScript("OnShow", frame.Hide) | ||
end | end | ||
Revision as of 17:50, 19 October 2008
← Widget API ← Frame < SetScript
Sets the action handler for this frame.
frame:SetScript("handler", function)
Parameters
Arguments
- ("handler", func)
- handler
- String - The handler to attach func to (OnShow, OnEvent, et al)
- func
- Function - The function to call. nil to remove the handler. func is called with arguments (frame, arg1, arg2, ...) (event being arg1 for OnEvent handlers)
Example
for i = 1, 4 do local frame = getglobal("PartyMemberFrame"..i) frame:SetScript("OnShow", frame.Hide) end
Result
All party frames will be hidden whenever they're shown.
PartyMemberFrame1:SetScript("OnShow", nil)
Result
Removes the OnShow handler from PartyMemberFrame1.