(See also)
Line 22: Line 22:
== See also ==
== See also ==
* {{api|Frame:GetScript|t=w}}
* {{api|Frame:GetScript|t=w}}
* {{api|Frame:HookScript|t = w}}
* {{api|Frame:HookScript|t=w}}
* [[Widget_handlers]]
* [[Widget_handlers]]

Latest revision as of 21:45, June 2, 2018

Widget API ← Frame < SetScript

Sets an event handler for a specific event type for this frame.

frame:SetScript("handler", func)

Parameters Edit

Arguments Edit

string - the name of the handler type, like 'OnShow', 'OnClick'. See Widget_handlers.
function - the Lua function to call or 'nil' to remove the handler

Examples Edit

for i = 1, 4 do
    local frame = _G["PartyMemberFrame"..i]
    frame:SetScript("OnShow", frame.Hide)

Adds an 'OnShow' event handler to all party frames to be called whenever they're shown.

PartyMemberFrame1:SetScript("OnShow", nil)

Removes whatever 'OnShow' handler was set from 'PartyMemberFrame1'.

See also Edit

Community content is available under CC-BY-SA unless otherwise noted.