Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement

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?Optional. Could be nil. - 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

See also

External links

References

  1. ^ a b Blizzard Entertainment Ornyx 2016-10-04. Notable UI Changes Coming in 7.1. Archived from the original
Advertisement