From 095665977f61df056608c6bfca1603ed2d500848 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 17 Jan 2024 14:52:05 +0100 Subject: [PATCH] Nav: marking NavId as hovered in ButtonBehavior() doesn't check for ActiveId. Aimed at allowing activating another item with a shortcut without losing NavId. Initial logic from c2cb2a69, with minor amends db5f1b79c, cea78cc57. --- docs/CHANGELOG.txt | 2 ++ imgui_widgets.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index be244c933..df56d4f26 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -47,6 +47,8 @@ Breaking changes: Other changes: - Nav: keyboard/gamepad activation mark widgets as held to give better visual feedback. +- Nav: tweak to logic marking navigated item as hovered when using keyboard, allowing + the hover highlight to stay even while another item is activated. - Fixed SetKeyboardFocusHere() not working when current nav focus is in different scope, regression from 1.90.1 related to code scoping Tab presses to local scope. (#7226) [@bratpilz] - Debug Tools: Metrics: Fixed debug break in SetShortcutRouting() not handling ImGuiMod_Shortcut redirect. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 2b648a604..bc71aa628 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -599,7 +599,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool // Gamepad/Keyboard navigation // 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.NavDisableMouseHover && (g.ActiveId == 0 || g.ActiveId == id || g.ActiveId == window->MoveId)) + if (g.NavId == id && !g.NavDisableHighlight && g.NavDisableMouseHover) if (!(flags & ImGuiButtonFlags_NoHoveredOnFocus)) hovered = true; if (g.NavActivateDownId == id)