From 836aff346700ee7e21ee4ba78568392faf285fd8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 27 Jun 2023 15:23:19 +0200 Subject: [PATCH] Drag and Drop: Amend ItemHoverable() logic for item with no identifier. Amend d5d4d70 --- imgui.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index a60c2f17..5c43cbd3 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4050,20 +4050,22 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) return false; } - // Drag source doesn't report as hovered - if (g.DragDropActive && g.DragDropPayload.SourceId == id && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoDisableHover)) - return false; - // We exceptionally allow this function to be called with id==0 to allow using it for easy high-level // hover test in widgets code. We could also decide to split this function is two. if (id != 0) + { + // Drag source doesn't report as hovered + if (g.DragDropActive && g.DragDropPayload.SourceId == id && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoDisableHover)) + return false; + SetHoveredID(id); + } // When disabled we'll return false but still set HoveredId if (item_flags & ImGuiItemFlags_Disabled) { // Release active id if turning disabled - if (g.ActiveId == id) + if (g.ActiveId == id && id != 0) ClearActiveID(); g.HoveredIdDisabled = true; return false;