Skip to content

PopupModal closes after selecting(cllicking) a MenuItem #5216

@dibalikpohon

Description

@dibalikpohon

Config/Build Information:

Dear ImGui 1.88 WIP (18717)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=202002
define: __linux__
define: __GNUC__=11
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000000
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1366.00,739.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

Version/Branch of Dear ImGui:

Version: 1.88
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Operating System: Pop!_Os 21.10

My Issue:

I want to have a menu(BeginMenu) inside a modal Window, but once I click one of the MenuItem, Dear ImGui closes the modal window.

Expecting:
Modal Window didn't close after a MenuItem is clicked.

Actual:
Modal Window closes after a MenuItem is clicked.

Screenshots/Video

dear_imgui.mp4

Code example:
https://pastebin.com/CSFS2nyu

Reproducible exampe, i guess?

ImGui::Begin("Modal test"); {
        ImGui::TextUnformatted("Click button to open modal");
        if (ImGui::Button("Here")) {
                ImGui::OpenPopup("Open modal");
        }
}

static bool theBooleans = false;
if (ImGui::BeginPopupModal("Open modal", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
        ImGui::TextUnformatted("wow");
        ImGui::MenuItem("outside BeginMenu", nullptr, false);
        if (ImGui::BeginMenu("options...")) {
                ImGui::MenuItem("(options)", nullptr, false, false);
                if (ImGui::MenuItem("inside BeginMenu", nullptr, theBooleans)) {
                    theBooleans = !theBooleans;
                }
                ImGui::MenuItem("Inside BeginMenu 1", nullptr, false);
                ImGui::EndMenu();
            }
            ImGui::EndPopup();
        }
}

ImGui::End();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions