![]() |
The API is no longer being updated here until further notice. |
Securely post-hooks a widget script handler.
success = ScriptRegion:HookScript(scriptTypeName, script [, bindingType])
Arguments
- scriptTypeName
- string - Name of the script type, for example "OnShow".
- script
- function - The function that will be called.
- bindingType
- number? - The intrinsic frame precall/postcall handler.
| Value | Enum | Description |
|---|---|---|
| 0 | LE_SCRIPT_BINDING_TYPE_INTRINSIC_PRECALL | |
| 1 | LE_SCRIPT_BINDING_TYPE_EXTRINSIC | Default |
| 2 | LE_SCRIPT_BINDING_TYPE_INTRINSIC_POSTCALL |
Returns
- success
- boolean - True if the script was successfully hooked.
Details
- If the script type doesn't have an existing handler, this will be equivalent to SetScript.
- Any hooks applied will remain in place until the UI is reloaded. But the original script can still be removed with
SetScript(scriptType, nil).
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 by e.g. switching between chat tabs.
ChatFrame1:HookScript("OnShow", function(self)
print("OnShow")
end)
ChatFrame1:HookScript("OnShow", function(self)
print("OnPostShow")
end, LE_SCRIPT_BINDING_TYPE_INTRINSIC_POSTCALL)
Patch history
Patch 7.1.0 (2016-10-25): Added bindingType[1]
Patch 3.0.8 (2009-01-20): Behaves like SetScript when the widget has no script.
Patch 2.1.0 (2007-05-22): Now hooks securely.
