possible to disable/remove a hook?
Ive been looking all night and cant find any mention of how to remove a hook.
Im looking to unregister events(which is no problem to do) and disable a posthook when a feature is disabled. its being enabled like this onload and when toggled on: Code:
ZO_PostHook("ZO_Armory_Keyboard_CollapsedEntry_OnMouseUp", MyAddon.MyFunction) |
The answer is: In theory yes, practical no.
Of course you could store the original reference and restore it at some point. But! If someone else is also hooking that, you would disable all hooks done after yours. Bad concept. So, no, you should not do this! What you could do is: Use a boolean for skipping any action. /edit: Or keep the hook, but the hook itself is just calling a function reference. Lua Code:
That is a so-called "tail call". See https://www.lua.org/pil/6.3.html |
Ya thats sort of what ive done... the beginning of the function checks is feature disabled and then return end if so.. else do the hook stuff :)..
Thank you I just wanted to be sure cuz I couldnt even find any mention of it nevermind how it would be done. SOO mysterious the answer was =p |
If you gus find out such stuff is missing, maybe add it to the Wiki please!
Added here: https://wiki.esoui.com/How_to_run_yo...#Disable_hooks |
All times are GMT -6. The time now is 09:04 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI