View Full Version : What Event Triggers On Main Map Closing?
Tunga
18-10-2006, 11:41 AM
The title should be fairly self explanatory - is there an event that fires whenever the user closes their main map and what's it called? A while ago I tried to make a mod that would remember what bags were open when I open the map and then re-open them again when I close the map. Sadly, I couldn't find a working event. Then I was busy so I gave up on it, but now I have some time again so does anyone know what I could use?
Cheers.
aspinkorgall
20-10-2006, 01:00 AM
http://www.wowwiki.com/Events/Map
I'd give CLOSE_WORLD_MAP a whack and see how that works out =)
Tunga
20-10-2006, 11:34 AM
Looks sensible, I can't honestly remember if I tried that before, thanks.
Does that mod still exist that tells you in chat what events are firing when so I can work this stuff out myself?
EDIT: Found the mod, it says this event isn't firing, ever :( . The mod could be wrong so I can try it in an actual mod but I remember finding an event before that looked like it should work and it didn't.
Can anyone think of an existing mod that might use this event?
aspinkorgall
21-10-2006, 02:11 AM
Unfortunately I'm once again not logged onto WoW when reading your thread so I can't test this before posting it.
However, if you take a look at the blizzard frames code, specifically the file FrameXML/WorldMapFrame.lua, it uses the event CLOSE_WORLD_MAP. This would suggest that it should work.
I'll try to take a look at it next time I'm online and see if I can catch the event, or figure out another way to do what youre asking.
xTwoStepx
21-10-2006, 04:08 AM
You could always hook the onClose script on the map window. and have that trigger whatever actions you want to fire.
Also, you could have an empty frame that in the OnUpdate() event, you check to see if WorldFrame(orwhatever its frame title is):IsVisible() and work with that, although not recommended as much since it may eat up framerates depending on what kind of code you are running.
Make sure you register the close event in your addon, otherwise it will never hear it if you go that route. Hope this gives you some ideas. BTW there is a way to stop the bags from closing when the map opens. the only downfall is that escape will no longer close them either. Look into the UISpecialFrames table and how it works.
aspinkorgall
21-10-2006, 11:48 AM
Trying to hook the onClose() function for the WorldMapFrame seems like the best way to go.
You might have tried hooking the function ToggleWorldMap(), but that wouldnt include non-keypress actions that close it (for example another addon closing it, or some other action like logging out, or other windows being opened).
Tunga
22-10-2006, 01:08 PM
Thanks for all the info.BTW there is a way to stop the bags from closing when the map opens. the only downfall is that escape will no longer close them either. Look into the UISpecialFrames table and how it works.This would be perfect, and sounds simple, I never use Esc to close the map anyway. Is there somewhere that tells me how it works though, WoWWiki is lacking any info on UISpecialFrames. I'm guessing something like...
table.remove(UISpecialFrames, "WorldMapFrame");...only it wants a number for the second argument which is confusing me. Thanks again :) .
EDIT: Ah, it's an index of course, so I just need to find the right frame in the table, right I think I can do that.
EDIT2: Maybe not...
for k,v in UISpecialFrames do
if v == (WorldMapFrame) then
table.remove(UISpecialFrames, k)
end
endThere's probably a basic error here, I'm still working out how LUA works really.
EDIT3: I got it to print out the table contents in game, there's no default frames in there, they're all things that have been added by other mods.
xTwoStepx
23-10-2006, 08:10 AM
The table contains Names (strings) not objects... so do a comparison for "WorldMapFrame" or whatever it was. sorry I don't feel like hitting the back button just yet. lol
You could always dump the contents of the table and see what is exactly in there. (I never did that lol i wonder really)
EDIT:
Oh sorry then. I recommend hooking the WorldMapFrame's OnClose Event. using the frame:GetScript() and frame():SetScript API using something like this...
WorldMapFrame_OnClose_orig = WorldMapFrame:GetScript("OnClose");
WorldMapFrame:SetScript("OnClose", My_WorldMapFrame_OnClose() );
function My_WorldMapFrame_OnClose()
-- do whatever i want to be done when map is closed...
-- then allow it to do what it was originally supposed to do.
WorldMapFrame_OnClose_orig();
end
Hope that gives you something to play with.
Tunga
24-10-2006, 10:34 AM
Thanks, that's brilliant again, I'll have a play with this when I get back from lectures. Been reading about the hooking on WoWwiki and that all makes sense, I'm starting to like LUA actually :) .
Tunga
25-10-2006, 05:26 PM
I get the error "WorldMapFrame doesn't have a "OnClose" script". I can see how the above should work but I guess that's not the way to do it :( .
Tunga
26-10-2006, 01:54 AM
There's seems to be a maximum time after which you can't edit posts so sorry for replying multiple times.
Just wanted to say that I have it working with OnHide instead of OnClose, but otherwise your code was perfect. It doesn't work when you press the X button on the map since that's when the CLOSE_WORLD_MAP should be firing which still doesn't work, but since I always open and close the map with a keybinding that isn't actually a problem. I think I can fix this by hooking one of the WorldMapFrame functions anyway :) .
xTwoStepx
26-10-2006, 08:08 AM
Im sorry. I wasn't thinking. its "OnHide"
Tunga
26-10-2006, 02:41 PM
I also just noticed that the CLOSE_WORLD_MAP event does fire, but only if you use Escape to close the map. I can't work out what function/event is being triggered when the X button is pressed on the map. Any ideas?
Tunga
26-10-2006, 04:24 PM
Well it works perfectly except for the X button, which is good enough for now (though I will see if I can work that out at some point). I've submitted it to ui.worldofwar too :) . Thanks a lot, I'll add a thanks to you both once it's accepted by an admin.
xTwoStepx
26-10-2006, 11:09 PM
Thats strange. I posted a reply yesturday but its no longer here... This site crapp'n out again?
Anyway, what i said was: "My bad... the SetScript() should be for "OnHide" not "OnClose"... Apparently I replied to you when I should have been sleeping.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.