BeginMenu(), MenuItem() use NextItemData.Flags + Fixed typo in comment. (#9456)

This commit is contained in:
ocornut
2026-07-01 12:38:00 +02:00
parent 9e6c0416fe
commit e408733ecc
2 changed files with 3 additions and 7 deletions

View File

@@ -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;
}