From 638e1a721be3f7f9a99ca2836165d6c12a6f0b4c Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 12 Jul 2021 15:00:35 +0200 Subject: [PATCH] Disabled: fixed IsItemHovered() returning true on disabled item when navigated to. (#211) --- docs/CHANGELOG.txt | 1 + imgui.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 696e4dbcc..1ece04d6d 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -63,6 +63,7 @@ Other Changes: - Disabled: disabled items set HoveredId, allowing e.g. HoveredIdTimer to function. (#211, #3419) [@rokups] - Disabled: disabled mode more consistently release active id if the active item got disabled. (#211) - Disabled: disabled mode doesn't prevent Selectable() from looking selected. (#211) +- Disabled: fixed IsItemHovered() returning true on disabled item when navigated to. (#211) - Fixed printf-style format checks on non-MinGW flavors. (#4183, #3592) - Fonts: Functions with a 'float size_pixels' parameter can accept zero if it is set in ImFontSize::SizePixels. - Fonts: Prefer using U+FFFD character for fallback instead of '?', if available. (#4269) diff --git a/imgui.cpp b/imgui.cpp index 80fb4bcaf..8ae49a84a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3162,7 +3162,11 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (g.NavDisableMouseHover && !g.NavDisableHighlight) + { + if ((g.CurrentItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) + return false; return IsItemFocused(); + } // Test for bounding box overlap, as updated as ItemAdd() ImGuiItemStatusFlags status_flags = window->DC.LastItemStatusFlags;