Skip to content

Commit d3ad2f3

Browse files
committed
Menus: Fixed an issue when opening a menu hierarchy in a given menu-bar would allow opening another via simple hovering. (#3496, #4797)
Amend 48f2633
1 parent b475079 commit d3ad2f3

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

docs/CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Other changes:
5050
unclipped bounding boxes would interfere with other columns. (#2221) [@zzzyap, @ocornut]
5151
- Nav: Fixed CTRL+Tab into a root window with only childs with _NavFlattened flags
5252
erroneously initializing default nav layer to menu layer.
53+
- Menus: Fixed an issue when opening a menu hierarchy in a given menu-bar would allow
54+
opening another via simple hovering. (#3496, #4797)
5355
- Debug Tools: Debug Log: Fixed not parsing 0xXXXXXXXX values for geo-locating on mouse
5456
hover hover when the identifier is at the end of the line. (#5855)
5557
- Backends: Clear bits sets io.BackendFlags on backend Shutdown(). (#6334, #6335] [@GereonV]

imgui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// Library Version
2424
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
2525
#define IMGUI_VERSION "1.89.6 WIP"
26-
#define IMGUI_VERSION_NUM 18953
26+
#define IMGUI_VERSION_NUM 18954
2727
#define IMGUI_HAS_TABLE
2828

2929
/*

imgui_widgets.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -7098,17 +7098,19 @@ static bool IsRootOfOpenMenuSet()
70987098

70997099
// Initially we used 'upper_popup->OpenParentId == window->IDStack.back()' to differentiate multiple menu sets from each others
71007100
// (e.g. inside menu bar vs loose menu items) based on parent ID.
7101-
// This would however prevent the use of e.g. PuhsID() user code submitting menus.
7101+
// This would however prevent the use of e.g. PushID() user code submitting menus.
71027102
// Previously this worked between popup and a first child menu because the first child menu always had the _ChildWindow flag,
7103-
// making hovering on parent popup possible while first child menu was focused - but this was generally a bug with other side effects.
7103+
// making hovering on parent popup possible while first child menu was focused - but this was generally a bug with other side effects.
71047104
// Instead we don't treat Popup specifically (in order to consistently support menu features in them), maybe the first child menu of a Popup
71057105
// doesn't have the _ChildWindow flag, and we rely on this IsRootOfOpenMenuSet() check to allow hovering between root window/popup and first child menu.
71067106
// In the end, lack of ID check made it so we could no longer differentiate between separate menu sets. To compensate for that, we at least check parent window nav layer.
71077107
// This fixes the most common case of menu opening on hover when moving between window content and menu bar. Multiple different menu sets in same nav layer would still
71087108
// open on hover, but that should be a lesser problem, because if such menus are close in proximity in window content then it won't feel weird and if they are far apart
71097109
// it likely won't be a problem anyone runs into.
71107110
const ImGuiPopupData* upper_popup = &g.OpenPopupStack[g.BeginPopupStack.Size];
7111-
return (window->DC.NavLayerCurrent == upper_popup->ParentNavLayer && upper_popup->Window && (upper_popup->Window->Flags & ImGuiWindowFlags_ChildMenu));
7111+
if (window->DC.NavLayerCurrent != upper_popup->ParentNavLayer)
7112+
return false;
7113+
return upper_popup->Window && (upper_popup->Window->Flags & ImGuiWindowFlags_ChildMenu) && ImGui::IsWindowChildOf(upper_popup->Window, window, true);
71127114
}
71137115

71147116
bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)

0 commit comments

Comments
 (0)