WoW:API hooksecurefunc: Difference between revisions
Jump to navigation
Jump to search
m
→Notes: No reason to prefix code with ">". Also, added note about :HookScript() being better than this function when you want to hook a frame's script handler.
(Added a note about hooking Blizzard frame event handler) |
m (→Notes: No reason to prefix code with ">". Also, added note about :HookScript() being better than this function when you want to hook a frame's script handler.) |
||
Line 46: | Line 46: | ||
It's simply because in Blizzard_MacroUI.xml the OnHide function call is registered like this: | It's simply because in Blizzard_MacroUI.xml the OnHide function call is registered like this: | ||
<OnHide function="MacroFrame_OnHide"/> | |||
The function ID called when the frame is hidden is the former one, before you | The function ID called when the frame is hidden is the former one, before you hooked "MacroFrame_OnHide". | ||
The workaround is to hook a function called by "MacroFrame_OnHide": | The workaround is to hook a function called by "MacroFrame_OnHide": | ||
hooksecurefunc(MacroPopupFrame, "Hide", MyFunction) | |||
However, when you want to hook a frame's script handler, it's better to use [[API_Frame_HookScript|Frame:HookScript]] like this: | |||
MacroPopupFrame:HookScript("OnHide", MyFunction) -- the client will call MacroFrame_OnHide(MacroPopupFrame) first followed by MyFunction(MacroPopupFrame) |