Widget API: Frame:HookScript
Jump to navigation
Jump to search
← Widget API ← Frame < HookScript
Post hooks a script handler (secure).
frame:HookScript("handler", function)
Parameters
Arguments
- ("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
for i = 1, 4 do local frame = _G["PartyMemberFrame"..i] frame:HookScript("OnClick", function(self, button) print(self:GetName() .. " clicked with " .. button) end) end
Result
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
- 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.