From 7e1678ff00cd9ad523a412b1ae16f49c04401f3a Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 31 Jul 2018 17:15:01 +0200 Subject: [PATCH] Drag and Drop: Elapse payload as soon as delivery is made. (#153) --- imgui.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 468f40862..546bb2a85 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4441,11 +4441,15 @@ void ImGui::EndFrame() // Show CTRL+TAB list if (g.NavWindowingTarget) NavUpdateWindowingList(); - - // Drag and Drop: Elapse payload (if source stops being submitted) - if (g.DragDropActive && g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) - if ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton)) + + // Drag and Drop: Elapse payload (if delivered, or if source stops being submitted) + if (g.DragDropActive) + { + bool is_delivered = g.DragDropPayload.Delivery; + bool is_elapsed = (g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton)); + if (is_delivered || is_elapsed) ClearDragDrop(); + } // Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing. if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount)