not works because probably it called after destroying frame and MacroFrame_OnHide not exists at this moment.
How to catch OnHide or OnClose? Or some other solution exists?
The Frames are not dynamic - there is no way to destroy a Frame. What is happening here is that those are internal Load on Demand AddOns - when you hook ShowMacroFrame (which is defined in UIParent.lua), the Blizzard_MacroUI AddOn has not yet been loaded (it is done so when ShowMacroFrame is called) so attempting to hook MacroFrame_OnHide will of course fail.
Instead...
- if your addon only deals with the macro frame, put Blizz's macro addon in your TOC on the "LoadsWith:" line and make your addon load on demand
- if you addon uses multiple frames (macro, pet journal, etc) which are created in LoD Blizz addons then watch for the ADDON_LOADED event for these addons
I'm catching not only OnShow/OnHide of MacroFrame, but also PetJournal, SpellBookFrame, PaperDollFrame - i.e. frame from which player can drag spells, mounts etc to put my addon in proper state. Last 2 frames was easy, MacroFrame and PetJournal harder.
Also I'm hooking OnHide to leave that state, so OnLoad not enough.
But how to catch OnClose or OnHide for such frames? Code not works because probably it called after destroying frame and MacroFrame_OnHide not exists at this moment.
How to catch OnHide or OnClose? Or some other solution exists?
I'd write more, but need to get ready for work.
- if your addon only deals with the macro frame, put Blizz's macro addon in your TOC on the "LoadsWith:" line and make your addon load on demand
- if you addon uses multiple frames (macro, pet journal, etc) which are created in LoD Blizz addons then watch for the ADDON_LOADED event for these addons
I'm catching not only OnShow/OnHide of MacroFrame, but also PetJournal, SpellBookFrame, PaperDollFrame - i.e. frame from which player can drag spells, mounts etc to put my addon in proper state. Last 2 frames was easy, MacroFrame and PetJournal harder.
Also I'm hooking OnHide to leave that state, so OnLoad not enough.