From 6b03ddbcb1dd0eb7f758ebca224d498aef31ff58 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 16 Nov 2015 22:43:42 +0100 Subject: [PATCH] Demo: Made the "menu inside a regular window" be in a different menuset. Added a comment (#409) --- imgui_demo.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index be675305e..71aca37d3 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1098,14 +1098,20 @@ void ImGui::ShowTestWindow(bool* opened) ImGui::EndPopup(); } + ImGui::Spacing(); ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!"); ImGui::Separator(); + // NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above. + // To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here + // would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus. + ImGui::PushID("foo"); ImGui::MenuItem("Menu item", "CTRL+M"); - if (ImGui::BeginMenu("Menu")) + if (ImGui::BeginMenu("Menu inside a regular window")) { ShowExampleMenuFile(); ImGui::EndMenu(); } + ImGui::PopID(); ImGui::Separator(); ImGui::TreePop();