From 3050f653cb5b6c79875659c4ac4bf43f9678e588 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 22 Jan 2026 17:33:35 +0100 Subject: [PATCH] Menus, Nav: made navigation into menu-bar auto wrap on X axis. (#9178) --- docs/CHANGELOG.txt | 1 + imgui.cpp | 2 +- imgui_widgets.cpp | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 63235b2c2..bd7715e2c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -135,6 +135,7 @@ Other Changes: - Menus: - Fixed MenuItem() label position and BeginMenu() arrow/icon/popup positions, when used inside a line with a baseline offset. + - Made navigation into menu-bar auto wrap on X axis. (#9178) - TreeNode: - Fixed highlight position when used inside a line with a large text baseline offset. (never quite worked in this situation; but then most of the time the text diff --git a/imgui.cpp b/imgui.cpp index 976216cb6..1f7115159 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -13436,7 +13436,7 @@ void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags wra // In theory we should test for NavMoveRequestButNoResultYet() but there's no point doing it: // as NavEndFrame() will do the same test. It will end up calling NavUpdateCreateWrappingRequest(). - if (g.NavWindow == window && g.NavMoveScoringItems && g.NavLayer == ImGuiNavLayer_Main) + if (g.NavWindow == window && g.NavMoveScoringItems && g.NavLayer == window->DC.NavLayerCurrent) g.NavMoveFlags = (g.NavMoveFlags & ~ImGuiNavMoveFlags_WrapMask_) | wrap_flags; } diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 8faf35e50..de19ecf28 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -9070,6 +9070,10 @@ void ImGui::EndMenuBar() NavMoveRequestForward(g.NavMoveDir, g.NavMoveClipDir, g.NavMoveFlags, g.NavMoveScrollFlags); // Repeat } } + else + { + NavMoveRequestTryWrapping(window, ImGuiNavMoveFlags_WrapX); + } PopClipRect(); PopID();