From db5f1b79cdb31d50d302f7052a8f25102ecfef57 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 13 Oct 2017 19:18:59 +0200 Subject: [PATCH] Nav: ButtonBehavior() keep _displaying_ NavId item as howered when refocusing or moving window, which is consistent with IsItemHovered() and reduce noise/flicker (#787) --- imgui.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index e856846a..fd16860c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2205,6 +2205,7 @@ static void NavMoveRequestCancel() NavUpdateAnyRequestFlag(); } +// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above) static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id) { ImGuiContext& g = *GImGui; @@ -6758,11 +6759,10 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool } // Gamepad/Keyboard navigation - if (g.NavId == id && !g.NavDisableHighlight && (g.ActiveId == 0 || g.ActiveId == id)) - { - // We report navigated item as hovered but we don't set g.HoveredId to not interfere with mouse + // We report navigated item as hovered but we don't set g.HoveredId to not interfere with mouse. + if (g.NavId == id && !g.NavDisableHighlight && (g.ActiveId == 0 || g.ActiveId == id || g.ActiveId == window->MoveId)) hovered = true; - } + if (g.NavActivateDownId == id) { bool nav_activated_by_code = (g.NavActivateId == id);