Package com.simsilica.lemur.dnd
Interface DragAndDropListener
- All Known Implementing Classes:
AbstractDragAndDropListener
public interface DragAndDropListener
Listener added to DragAndDropControls to perform the drag start,
drag over, and drop operations. It is up to the listener on the
source control to allow the drag session to be initiated. The
listeners on the drop targets can then indicate the status of
the potential drop, accept the drop, and so on. Finally, when
the drag is complete, the listener on the drag source is notified
that the operation is done.
Event lifecycle (in order):
- SOURCE: onDragDetected() called when the drag gesture is initiated. The application provided implementation returns a Draggable if the drag session should start or null if the drag should not be started.
- TARGET: onDragEnter() called when the Draggable is over a new target.
- TARGET: onDragOver() called for motion over the target. The application provided implementation can set the DragSession's drag status to indicate whether a drop would succeed or not.
- TARGET: onDragExit() called when the Draggable is no longer over this target
- TARGET: onDrop() called when the user releases the drag over this target. The application provided implementation can do the steps to move the data to its new container and has one last chance to indicate failure.
- SOURCE: onDragDone() called on the source when the user releases the drag. This allows the source to clean itself up and/or return the item if the drag was unsuccessful.
Note: in all cases above, the SOURCE and the TARGET may be the same container and listeners handle this as appropriate.
-
Method Summary
Modifier and TypeMethodDescriptiononDragDetected
(DragEvent event) Called when the drag gesture is first detected by the drag container.void
onDragDone
(DragEvent event) Called on listeners on the SOUCE container when the drag operation is completed, regardless of whether the drop was successful.void
onDragEnter
(DragEvent event) Called when the draggable has entered the drag-and-drop container to which this listener is listening.void
onDragExit
(DragEvent event) Called when the draggable has left the drag-and-drop container to which this listener is listening.void
onDragOver
(DragEvent event) Called for all draggable motion over the drag-and-drop container to which this listener is listening.void
Called on listeners on the TARGET container when a drag operation is completed and the drag status at the time was DragStatus.ValidTarget.
-
Method Details
-
onDragDetected
Called when the drag gesture is first detected by the drag container. It is up to the implementation to return a proper Draggable or not depending on if the drag operation is valid at the event's location. Return null if no drag operation should commence. -
onDragEnter
Called when the draggable has entered the drag-and-drop container to which this listener is listening. -
onDragExit
Called when the draggable has left the drag-and-drop container to which this listener is listening. -
onDragOver
Called for all draggable motion over the drag-and-drop container to which this listener is listening. -
onDrop
Called on listeners on the TARGET container when a drag operation is completed and the drag status at the time was DragStatus.ValidTarget. It is up to the listeners to decide if the drag was successful or failed by setting the session's drag status. By default, drop operations succeed unless the listeners set the status to DragStatus.InvalidTarget. -
onDragDone
Called on listeners on the SOUCE container when the drag operation is completed, regardless of whether the drop was successful. This allows the source container to either refresh undropped item or clean its view up now that the item is gone 'for real'.
-