-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
RFC: Drag and Drop API #5863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
RFC: Drag and Drop API #5863
Conversation
| URI() URI | ||
| } | ||
|
|
||
| type DragItemCursor interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Cursor is a desktop extension, so a DragCursor should be too.
What might be good to handle at this level would be the drag preview which would appear next to the cursor and floating above the content, where desired?
| // onto another CanvasObject which implements DropTarget. | ||
| type DragSource interface { | ||
| // DragSourceBegin is invoked when a drag and drop is initiated on this DragSource. | ||
| // It should return the DragItems it is sourcing, and optionally a non-nil DragItemCursor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not bake cursors into the main abstraction. Perhaps the DragItem could optionally implement DragItemCursor? Or even just Cursorable?
|
|
||
| // DragSourceDragged is invoked when a drag and drop continues within this DragSource | ||
| // and has not yet entered over a potential DropTarget. | ||
| DragSourceDragged(*PointEvent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what this adds? Isn't it just the same as Hoverable except the widget has initiated a drag? (which it already knows)
| // which MAY be a subset of the items returned by DragSourceBegin. | ||
| // Implementations may wish to use this hook to update rendering to | ||
| // highlight the item(s) which may be about to be dropped. | ||
| DropPending([]DragItem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a concrete example of this in use? I'm not entirely sure that it will be supported at the OS level...
| // that DropTarget, but the drag still remains in progress. | ||
| // Implementations may wish to cancel any visual changes made in response | ||
| // to the corresponding DropPending invocation. | ||
| DropUnpending() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the above is not needed then neither is this. Feels cleaner without - but I didn't quite understand the use-case
| // accepted by a DropTarget. | ||
| DropCanceled() | ||
|
|
||
| // DropCanceled is invoked when a drag and drop ends with the content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, just FYI :)
| // the in-progress drag and drop operation. | ||
| // If both the DragSource and this DropTarget return a cursor, the DropTarget | ||
| // cursor will be used to represent the drag and drop while it is dragged over this target. | ||
| DropBegin(*PointEvent, []DragItem) (accept []DragItem, cursor DragItemCursor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above I don't think that cursor implementation is needed at this level - we already support that through Cursorable in the desktop extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to that I'm not sure that the implication in the comments that the cursor of the initialing drag would remain in use throughout the operation necessarily stands (normally).
| // (resulting in a DropBegin invocation) continues to be dragged within this DropTarget. | ||
| // Implementations may wish to update rendering to show where the dragged content | ||
| // would land if dropped. | ||
| DropDragged(*PointEvent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this and DropEnd needed? we already handle dragging in a non dnd operation, so if the position matters it can still be discovered...
| DropEnd() | ||
|
|
||
| // Dropped is invoked when a drag and drop ends by being dropped on this DropTarget. | ||
| Dropped(*PointEvent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the []DragItem more important than the *PointEvent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all of this, a great bit of work towards fleshing it out.
I worry however that it is almost a super-set of DnD + cursor management + draggable, so have notes inline about how it could be trimmed down.
It looks like it could support the OS level integrations but the docs write very specifically about dragging to (or from) other CanvasObjects - but probably we don't want to limit to that?
Description:
RfC / Draft of API to allow drag and drop between CanvasObjects
For #142
Example use cases
Dragging to reorder items in a list (with possible multi-selection)
Dragging DocTabs items from one DocTabs widget to another (eg multi-pane text editor)
Dragging items from one top-level Fyne window to another window in the same app (process)
Open questions
Checklist:
Where applicable: