The API is no longer being updated here until further notice. |
Securely post-hooks a script handler.
success = ScriptObject:HookScript(scriptType, handler [, bindingType])
Arguments
- scriptType
- string - Name of the script type, e.g. "OnShow".
- handler
- function - The function to call; will be passed all arguments relevant for the hooked frame script type.
- bindingType
- number? - Specifies any intrinsic frame's pre/post handler to hook.
Enum LE SCRIPT BINDING TYPE
Returns
- success
- boolean - Returns true if the hook was successfully installed, false if not.
Details
- If the widget script type doesn't have an existing handler function, one will be created as if you called ScriptObject:SetScript()
- An intrinsic Frame can have irrevocable pre/post handlers. These cannot be set or changed, but they can be securely post-hooked using
bindingType
[1]. Hooking a nonexistent pre/post handler fails with a return value of false.
Example
Prints when you open the character frame.
/run CharacterFrame:HookScript("OnShow", function(self) print(self:GetName().." was shown") end)
Prints when ChatFrame1 is shown when e.g. switching between chat tabs.
ChatFrame1:HookScript("OnShow", function(self) print(self:GetName().." was shown (extrinsic)") end) ChatFrame1:HookScript("OnShow", function(self) print(self:GetName().." was shown (postcall)") end, LE_SCRIPT_BINDING_TYPE_INTRINSIC_POSTCALL)
Patch history
- Patch 7.1.0 (2016-10-25): Added third argument bindingType.[1]
- Patch 2.1.0 (2007-05-22): Now hooks securely.
See also
External links
- GitHub FrameXML, Gethe
- Globe "wut?" Tool, Townlong-Yak
- wowprogramming, Jim Whitehead
References
- ^ a b Ornyx 2016-10-04. Notable UI Changes Coming in 7.1. Archived from the original