How to get function from standard wow ui
Hello.
I am trying to make an addon that can share and import macros between player in-game. I got most of the logic working, but i am now struggling with addon a shift+click function to the standard "MacroButtonX" buttons in the macro-frame. Any suggestions or ideas as to how i modify the function of a wow standard ui element such as the macro buttons? Thanks on advance! |
Basically, what you're asking for is a way to hook a function, namely a standard Blizzard function.
Hooking functions insecurely is usually a bad idea, specially if they are Blizzard ones. You will cause taint, which will spread to other parts of the UI (both Blizzard and other addons' elements), which will trigger events like ADDON_ACTION_BLOCKED or ADDON_ACTION_FORBIDDEN (and I'm talking about actions from sources other than your addon (Blizzard or other addons), even though the culprit will be your own hook. Still, for the sake of understanding, I'll show you how to do an insecure hook first, and then link to the secure hooking functons the Blizzard API provides. #1: Insecure hook on function "standardFunction" (full replacement): Code:
myFunction = function() Code:
oldFunction = standardFunction; As a rule of thumb, you should only fully replace or prehook a function of your own (in the same addon of yours or a global function from another addon of yours). #3: Insecure hook on function "standardFunction" (posthook, i.e. with callback to the original function first): Code:
oldFunction = standardFunction; The standard API provides two functions (and a (big) little something else) to securely posthook functions (both Blizzard's and other addons'). For more details please see: API hooksecurefunc API Frame HookScript You can also look at RestrictedEnvironment, SecureHandlers and the SecureStateDriver (as starting points to the whole thing). |
All times are GMT -6. The time now is 04:09 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI