From 088487a3d44dc75db73ed4aff9bbd224604102ac Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 13 Apr 2022 12:34:13 +0200 Subject: [PATCH] Nav: Fixed nav movement in a scope with only one disabled item from focusing the disabled item. (#5189) --- docs/CHANGELOG.txt | 1 + imgui.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 8bef0a4d..dedad70e 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -61,6 +61,7 @@ Other Changes: - InputScalar: Fixed manual input when using %03d style width in display format string. (#5165, #3133) - InputScalar: Automatically allow hexadecimal input when format is %X (without extra flag). - InputScalar: Automatically allow scientific input when format is float/double (without extra flag). +- Nav: Fixed nav movement in a scope with only one disabled item from focusing the disabled item. (#5189) - IsItemHovered(): added ImGuiHoveredFlags_NoNavOverride to disable the behavior where the return value is overriden by focus when gamepad/keyboard navigation is active. - InputText: Fixed pressing Tab emitting two tabs characters because of dual Keys/Chars events being diff --git a/imgui.cpp b/imgui.cpp index c7aefc44..376eea9a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9724,10 +9724,10 @@ static void ImGui::NavProcessItem() const ImGuiItemFlags item_flags = g.LastItemData.InFlags; // Process Init Request - if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent) + if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent && (item_flags & ImGuiItemFlags_Disabled) == 0) { // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback - const bool candidate_for_nav_default_focus = (item_flags & (ImGuiItemFlags_NoNavDefaultFocus | ImGuiItemFlags_Disabled)) == 0; + const bool candidate_for_nav_default_focus = (item_flags & ImGuiItemFlags_NoNavDefaultFocus) == 0; if (candidate_for_nav_default_focus || g.NavInitResultId == 0) { g.NavInitResultId = id;