Wikia

WoWWiki

API Frame HookScript

Talk0
101,555pages on
this wiki
Widget API


Post hooks a script handler (secure).

frame:HookScript("handler", function)

Parameters Edit

Arguments Edit

("handler", func)
handler 
String - The handler to attach func to (OnShow, OnEvent, et al)
func 
Function - The function to call. Unlike :SetScript(), nil throws an error. func is called with arguments (frame, arg1, arg2, ...) (event being arg1 for OnEvent handlers)

Example Edit

for i = 1, 4 do
    local frame = _G["PartyMemberFrame"..i]
    frame:HookScript("OnClick", function(self, button)
        print(self:GetName() .. " clicked with " .. button)
    end)
end

ResultEdit

Alert the player when he clicks a party member's portrait while preserving the security of the unit frame after calling its original handler.

Notes Edit

  • Just like hooksecurefunc, this can be used on secure code.
  • If the frame doesn't have a func for handler, one will be created as if you called :SetScript("handler", func).
  • Every script handler has at least one argument (the frame itself, usually self). See widget handlers for details on each handler.


Around Wikia's network

Random Wiki