Skip to content

BUG: Modal MenuBar doesn't close when clicked off #4797

@AACodek

Description

@AACodek

Version Info

Dear ImGui 1.86 WIP (18518)
--------------------------------
sizeof(size_t): 4, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201103
define: IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
define: _WIN32
define: __MINGW32__
define: __GNUC__=8
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx11
io.ConfigFlags: 0x00000000
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMoveFromTitleBarOnly
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,256
io.DisplaySize: 1920.00,1009.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Backends/OS
#include "backends/imgui_impl_win32.cpp"
#include "backends/imgui_impl_dx11.cpp"

Issue
Modal 'File Menu' Does not close when clicked off menu (IE Cancel menu dropdown)

ImGui::Begin("Dummy Window", &open);
if (ImGui::Button("Test"))
ImGui::OpenPopup("Broken Modal");

ImGui::SetNextWindowSize(ImVec2(480, 480));
if (ImGui::BeginPopupModal("Broken Modal", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_MenuBar))
{
    
    if (ImGui::BeginMenuBar())
    {
        if (ImGui::BeginMenu("File"))
        {
            if (ImGui::MenuItem("CLOSE"))
            {
                ImGui::CloseCurrentPopup();
            }

            ImGui::EndMenu();
        }
        ImGui::EndMenuBar();
    }

    if (ImGui::Button("Close (try File->Close)"))
        ImGui::CloseCurrentPopup();

    ImGui::Text("Click 'File', then click off anywhere...\n"
                "File menu, should have been closed");
    ImGui::EndPopup();
}
ImGui::End();

XXX (please provide as much context as possible)

Screenshots/Video

2021-12-09.15-12-58.mp4

Video of me clicking off the File Menu, however it doesn't close.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions