|
@@ -7177,21 +7177,19 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|
|
|
|
|
void ImGui::EndMenu()
|
|
|
{
|
|
|
- // Nav: When a left move request _within our child menu_ failed, close ourselves (the _parent_ menu).
|
|
|
- // A menu doesn't close itself because EndMenuBar() wants to catch the last Left<>Right inputs.
|
|
|
- // However, it means that with the current code, a BeginMenu() from outside another menu or a menu-bar won't be closable with the Left direction.
|
|
|
- // FIXME: This doesn't work if the parent BeginMenu() is not on a menu.
|
|
|
+ // Nav: When a left move request our menu failed, close ourselves.
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginMenu()/EndMenu() calls
|
|
|
-
|
|
|
+ ImGuiWindow* parent_window = window->ParentWindow; // Should always be != NULL is we passed assert.
|
|
|
if (window->BeginCount == window->BeginCountPreviousFrame)
|
|
|
- if (g.NavMoveDir == ImGuiDir_Left && NavMoveRequestButNoResultYet() && window->DC.LayoutType == ImGuiLayoutType_Vertical)
|
|
|
- if (g.NavWindow && (g.NavWindow->RootWindowForNav->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->RootWindowForNav->ParentWindow == window)
|
|
|
+ if (g.NavMoveDir == ImGuiDir_Left && NavMoveRequestButNoResultYet())
|
|
|
+ if (g.NavWindow && (g.NavWindow->RootWindowForNav == window) && parent_window->DC.LayoutType == ImGuiLayoutType_Vertical)
|
|
|
{
|
|
|
- ClosePopupToLevel(g.BeginPopupStack.Size, true);
|
|
|
+ ClosePopupToLevel(g.BeginPopupStack.Size - 1, true);
|
|
|
NavMoveRequestCancel();
|
|
|
}
|
|
|
+
|
|
|
EndPopup();
|
|
|
}
|
|
|
|