1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-30 03:10:06 +00:00

Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceExtern assume a mouse button being pressed. (#143)

This commit is contained in:
ocornut 2024-06-19 19:02:51 -07:00
parent 413c056359
commit 50709454b3
2 changed files with 9 additions and 3 deletions

View file

@ -5136,7 +5136,7 @@ void ImGui::EndFrame()
if (g.DragDropActive)
{
bool is_delivered = g.DragDropPayload.Delivery;
bool is_elapsed = (g.DragDropSourceFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton));
bool is_elapsed = (g.DragDropSourceFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || g.DragDropMouseButton == -1 || !IsMouseDown(g.DragDropMouseButton));
if (is_delivered || is_elapsed)
ClearDragDrop();
}
@ -13239,6 +13239,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
window = NULL;
source_id = ImHashStr("#SourceExtern");
source_drag_active = true;
mouse_button = g.IO.MouseDown[0] ? 0 : -1;
KeepAliveID(source_id);
SetActiveID(source_id, NULL);
}
@ -13439,7 +13440,10 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
RenderDragDropTargetRect(r, g.DragDropTargetClipRect);
g.DragDropAcceptFrameCount = g.FrameCount;
payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting OS window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
if ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) && g.DragDropMouseButton == -1)
payload.Delivery = was_accepted_previously && (g.DragDropSourceFrameCount < g.FrameCount);
else
payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting OS window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery))
return NULL;