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`.
This commit is contained in:
Antoine Beyeler 2024-12-12 19:47:41 +01:00 committed by GitHub
parent ea89c2935e
commit ba060a2c87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -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;
}
});
}
}
}