From 6e99688fa74b3de5694a8e021619cc1ade51ee03 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 7 Apr 2015 14:03:17 +0100 Subject: [PATCH] Fixed user-facing version of IsItemHovered() ignoring overlapping windows --- imgui.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 9361deb0..7b056e94 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4347,11 +4347,9 @@ static bool IsHovered(const ImRect& bb, ImGuiID id) { ImGuiWindow* window = GetCurrentWindow(); if (g.HoveredRootWindow == window->RootWindow) - { if ((g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdIsFocusedOnly) && IsMouseHoveringRect(bb)) if (IsWindowContentHoverable(g.HoveredRootWindow)) return true; - } } return false; } @@ -7215,9 +7213,10 @@ static bool ItemAdd(const ImRect& bb, const ImGuiID* id) // So that clicking on items with no active id such as Text() still returns true with IsItemHovered() window->DC.LastItemHoveredRect = true; window->DC.LastItemHoveredAndUsable = false; - if (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdIsFocusedOnly || (g.ActiveId == window->MoveID)) - if (IsWindowContentHoverable(window)) - window->DC.LastItemHoveredAndUsable = true; + if (g.HoveredRootWindow == window->RootWindow) + if (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdIsFocusedOnly || (g.ActiveId == window->MoveID)) + if (IsWindowContentHoverable(window)) + window->DC.LastItemHoveredAndUsable = true; } else {