WoW:API Frame SetScript: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Sets the action handler for this frame or removes the handler with a nil function
<center>'''Frame:SetScript''' ''-Documentation by [[user:Author|Author]]-''</center>


frame:SetScript(''"handler"'', ''function'');
Sets the action handler for this frame.


----
  frame:SetScript("handler", function)
; ''Arguments:'' : <br>'''"handler"''' is the action to set, i.e. "OnShow" or "OnEvent".<br>'''function''' is the function you want to set for the handler.<br>
----
; ''Example 1:'' :
  for i = 1, 4 do<br> local frame = getglobal("PartyMemberFrame"..i);<br> frame:SetScript("OnShow", function() this:Hide(); end);<br>end


; ''Result:'' : All party frames will be hidden whenever they're shown.
== Parameters ==
=== Arguments ===
<!-- List each argument, together with its type -->
:("handler", func)


:;handler : String - The handler to attach func to (OnShow, OnEvent, et al)
:;func : Function - The function to call.  <tt>nil</tt> to remove the handler.


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


PartyMemberFrame1:SetScript("OnShow", nil);
====Result====
All party frames will be hidden whenever they're show.


; ''Result:'' : Removes the OnShow handler function of PartyMemberFrame1.
PartyMemberFrame1:SetScript("OnShow", nil)
====Result====
Removes the OnShow handler from PartyMemberFrame1.


__NOTOC__
{{template:WoW API}}
{{template:WoW API}}

Revision as of 20:36, 14 January 2006

Frame:SetScript -Documentation by Author-

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.

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

PartyMemberFrame1:SetScript("OnShow", nil)

Result

Removes the OnShow handler from PartyMemberFrame1.


Template:WoW API