WoW:API Frame SetScript: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Nuke author line)
Line 11: Line 11:


:;handler : String - The handler to attach func to (OnShow, OnEvent, [[XML_User_Interface#Event_Handler_reference|et al]])
:;handler : String - The handler to attach func to (OnShow, OnEvent, [[XML_User_Interface#Event_Handler_reference|et al]])
:;func : Function - The function to call.  <tt>nil</tt> to remove the handler.
:;func : Function - The function to call.  <tt>nil</tt> to remove the handler. <tt>func</tt> is called with arguments <tt>(frame, event, arg1, arg2, ...)</tt>


== Example ==
== Example ==

Revision as of 16:36, 16 July 2007

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, event, arg1, arg2, ...)

Example

for i = 1, 4 do
    local frame = getglobal("PartyMemberFrame"..i)
    frame:SetScript("OnShow", function() this:Hide() end)
end

Result

All party frames will be hidden whenever they're shown.

PartyMemberFrame1:SetScript("OnShow", nil)

Result

Removes the OnShow handler from PartyMemberFrame1.