From 90743d3112a703309b9e256ee1d3a3ec90c14b2d Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 12 Mar 2026 19:12:47 +0100 Subject: [PATCH] Nav: allow ImGuiKey_Menu or Shift + F10 to work on Begin()...BeginPopupContextItem() sequence aiming at title bar. (#8803, #9270) --- imgui.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 5e4c1606b..fb7e09a56 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -12507,7 +12507,7 @@ bool ImGui::IsPopupOpenRequestForItem(ImGuiPopupFlags popup_flags, ImGuiID id) ImGuiMouseButton mouse_button = GetMouseButtonFromPopupFlags(popup_flags); if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) return true; - if (g.NavOpenContextMenuItemId == id && IsItemFocused()) + if (g.NavOpenContextMenuItemId == id && (IsItemFocused() || id == g.CurrentWindow->MoveId)) return true; return false; } @@ -14251,6 +14251,11 @@ static void ImGui::NavUpdateContextMenuRequest() return; g.NavOpenContextMenuItemId = g.NavId; g.NavOpenContextMenuWindowId = g.NavWindow->ID; + + // Allow triggering for Begin()..BeginPopupContextItem(). A possible alternative would be to use g.NavLayer == ImGuiNavLayer_Menu. + if (g.NavId == g.NavWindow->GetID("#CLOSE") || g.NavId == g.NavWindow->GetID("#COLLAPSE")) + g.NavOpenContextMenuItemId = g.NavWindow->MoveId; + g.NavInputSource = ImGuiInputSource_Keyboard; SetNavCursorVisibleAfterMove(); }