From e408733eccd89b7a2c0f0013a202cc48e199465b Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 1 Jul 2026 12:38:00 +0200 Subject: [PATCH] BeginMenu(), MenuItem() use NextItemData.Flags + Fixed typo in comment. (#9456) --- imgui.cpp | 2 +- imgui_widgets.cpp | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index f6fb61dcd..addbe5e9a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1519,7 +1519,7 @@ ImGuiStyle::ImGuiStyle() GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. LogSliderDeadzone = 4.0f; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero. ImageRounding = 0.0f; // Rounding of Image() calls. - ImageBorderSize = 0.0f; // Thickness of border around tabs. + ImageBorderSize = 0.0f; // Thickness of border around Image() calls. TabRounding = 5.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. TabBorderSize = 0.0f; // Thickness of border around tabs. TabMinWidthBase = 1.0f; // Minimum tab width, to make tabs larger than their contents. TabBar buttons are not affected. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index c8458eba1..7b770b433 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -9382,7 +9382,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled) // This is only done for items for the menu set and not the full parent window. const bool menuset_is_open = IsRootOfOpenMenuSet(); if (menuset_is_open) - PushItemFlag(ImGuiItemFlags_NoWindowHoverableCheck, true); + g.NextItemData.ItemFlags |= ImGuiItemFlags_NoWindowHoverableCheck; // The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu, // However the final position is going to be different! It is chosen by FindBestWindowPosForPopup(). @@ -9445,8 +9445,6 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled) } const bool hovered = (g.HoveredId == id) && enabled && !g.NavHighlightItemUnderNav; - if (menuset_is_open) - PopItemFlag(); bool want_open = false; bool want_open_nav_init = false; @@ -9609,7 +9607,7 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut // See BeginMenuEx() for comments about this. const bool menuset_is_open = IsRootOfOpenMenuSet(); if (menuset_is_open) - PushItemFlag(ImGuiItemFlags_NoWindowHoverableCheck, true); + g.NextItemData.ItemFlags |= ImGuiItemFlags_NoWindowHoverableCheck; // We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73), // but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only. @@ -9680,8 +9678,6 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut if (!enabled) EndDisabled(); PopID(); - if (menuset_is_open) - PopItemFlag(); return pressed; }