API ScriptObject HookScript
Securely post-hooks a script handler.
- String - The handler to hook to, e.g. "OnShow". See Widget handlers.
- Function - The function to call; will be passed all arguments relevant for the hooked widget handler type. May not be
The following snippet prints a message when the player clicks a party member's unit frame. Notably, the hook does not taint the original click handler, allowing the frames to continue to target the relevant party members.
for i = 1, 4 do _G["PartyMemberFrame"..i]:HookScript("OnClick", function(self, button) print(self:GetName() .. " clicked with " .. button) end) end
- Just like hooksecurefunc, this can be used to hook secure handlers.
- If the frame doesn't have an existing function handling "handler", one will be created as if you called Frame:SetScript.
- Every script handler has at least one argument (the frame itself, usually self). See widget handlers for details on each handler.