From ba060a2c878bfefa5aead8e5fe0b9e69ab4c9048 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler <49431240+abey79@users.noreply.github.com> Date: Thu, 12 Dec 2024 19:47:41 +0100 Subject: [PATCH] Drag-and-drop: keep cursor set by user, if any (#5467) We used to always set the cursor to `Grabbing` when a drag and drop payload is set, but this shadows user code trying to set an alternative cursor (e.g. `NoDrop`). This PR no only change the cursor to `Grabbing` if is way previously set to `Default`. --- crates/egui/src/drag_and_drop.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/drag_and_drop.rs b/crates/egui/src/drag_and_drop.rs index e1997800834..fc9f29f5e03 100644 --- a/crates/egui/src/drag_and_drop.rs +++ b/crates/egui/src/drag_and_drop.rs @@ -57,7 +57,13 @@ impl DragAndDrop { if abort_dnd_due_to_mouse_release { Self::clear_payload(ctx); } else { - ctx.set_cursor_icon(CursorIcon::Grabbing); + // We set the cursor icon only if its default, as the user code might have + // explicitly set it already. + ctx.output_mut(|o| { + if o.cursor_icon == CursorIcon::Default { + o.cursor_icon = CursorIcon::Grabbing; + } + }); } } }