View Single Post
09-27-20, 04:05 PM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
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")
testButton:SetPoint("CENTER", 0, 0)
testButton:SetFrameStrata("FULLSCREEN")
testButton:SetWidth(230)
testButton:SetHeight(80)

testButton:SetText("Click to hide world map!")

testButton:SetScript("OnClick", function()
    if InCombatLockdown() then
      WorldMapFrame:Hide()
    else
      HideUIPanel(WorldMapFrame)
    end
  end)
  • Open the map like you normally do.
  • Click the button while in combat.
  • Try the ESC key afterwards (or whatever key you have assigned to "Toggle Game Menu") and see that it is not working.


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")
testButton:SetPoint("CENTER", 0, 0)
testButton:SetFrameStrata("FULLSCREEN")
testButton:SetWidth(230)
testButton:SetHeight(80)

testButton:SetText("Click to hide world map!")

testButton:SetScript("OnClick", function()
    WorldMapFrame:Hide()
  end)
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote