ToggleGameMenu() not working after WorldMapFrame:Hide()
I want a button to hide the WorldMapFrame (even during combat).
The only way to do this seems to be WorldMapFrame:Hide(), because all other ways I could think of (HideUIPanel(WorldMapFrame), ToggleWorldMap(), WorldMapFrame:SetDisplayState(1)) are not allowed during combat. The problem is: after I have hidden the map this way, the ESC key (Toggle Game Menu) is not working any more. I.e. ToggleGameMenu() is called but without any effect. Neither does my character leave combat nor is the game menu shown. Any idea what is causing this and if there is a way around it? Here is a minimal working example: Code:
testButton = CreateFrame("Button", nil, WorldMapFrame, "UIPanelButtonTemplate")
If you don't want to seek out a target dummy, you can also simplify the demonstration to get the same effect regardless of whether you are in combat or not. But be aware that I need to hide the map during combat! Code:
testButton = CreateFrame("Button", nil, WorldMapFrame, "UIPanelButtonTemplate") |
Works fine using WorldMapFrame:Hide() OR HideUIPanel(WorldMapFrame) while in combat and esc. after to open the game menu..
You've made testButton global, not sure what that might be doing. This is in retail. |
(Regarding the global button variable: you are of course right. I just did not pay that much attention when creating the example.)
But that it works for you is hard to believe. I have just checked again and made sure that all other addons except the minimal working example are disabled. For both retail and ptr it is as I have described. I added Code:
hooksecurefunc("ToggleGameMenu", function(...) https://youtu.be/Zz03Ttjjqvc It also shows that once you have opened and closed the map "regularly" (here clicking the close button), ESC works again as expected, until you WorldMapFrame:Hide() it again with my button. |
You're right, the HideUIPanel didn't work in combat but the game menu did.
Remember, the first Esc. is possibly being chewed clearing the target so you have to press it twice. |
So you are saying that after opening the map and then hiding it with /run WorldMapFrame:Hide(), your ESC key is still working?
(In my video you can see how often I press ESC: "You pressed ESC" being printed to the console.) |
Lua Code:
Open the map, enter combat with target dummy, press the button. press esc. twice (first clears the dummy), game menu opens. |
What's going on here?? What class are you trying this with?
In my video I used a DemonHunter, where pressing ESC does neither cancel combat nor open the menu. When I tried a warlock, pressing ESC did in fact cancel the auto-cast but did not open the menu upon any subsequent ESC presses. |
HD, Mage, Hunter.. all work (happy to try anything else you like).
If esc. doesn't cancel combat/targeting, it sounds like a keybind or other addon problem. |
I had all other addons disabled.
Have you tried it with all other addons disabled? I just noticed that when I have "Mapster" activated at the same time, the issue is not there. At least I could now go and see what mapster does to prevent it. |
You are indeed correct. It does seem they've protected the closing for some reason.
Opening the map and pressing escape restores the game menu on escape, so some investigation as to what's going on would be needed. |
OK, good to know that it is at least reproducible. :-)
I think I will break down Mapster to find and then copy whatever it does to prevent this effect from happening. |
Excuse me for asking, but why do you want an extra button for this?
If you used a keybinding to open the map you can just press it again (or press esc) and if you're a clicker you can just click the close button? Nevertheless I quickly tested it on beta and securecall("CloseAllWindows") (called by ToggleGameMenu()) still returns the WorldMapFrame after hiding the frame, that's why it stops there and doesnt open the menu. Just hiding the map frame isn't the same as closing it - open your character frame after hiding the map, it will not be correctly anchored to the left side of the screen, instead it's next to the invisible map and fixing that requires calling secure code which we can't do. |
Quote:
I am able to do all this, except that ToggleGameMenu() does not work any more afterwards. |
It turns out you can get this to work if you do.
Code:
UIPanelWindows["WorldMapFrame"] = nil |
I think this is the best way to go:
Code:
testButton:SetScript("OnClick", function() |
Quote:
|
Quote:
Code:
hooksecurefunc(WorldMapFrame, "SetMapID", |
All times are GMT -6. The time now is 03:51 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI