Drag[en]gine Script Module DragonScript  1.23
Dragengine.Gui.DefaultDragAndDrop Class Reference

Default implementation of DragAndDrop. More...

Inheritance diagram for Dragengine.Gui.DefaultDragAndDrop:
Dragengine.Gui.DragAndDrop

Classes

class  TrackDragListener
 Drag processing listener. More...
 

Public Member Functions

void addSupportedDataType (String type)
 Add supported drag type. More...
 
void beginDrag (int mouseButton)
 Begin drag and drop operation. More...
 
void dropDone (bool success)
 Drop has been processed. More...
 
void endDrag (bool abord)
 End drag and drop operation. More...
 
bool getCanDrop ()
 Drop action is valid on the target. More...
 
DNDTypeList getDataTypes ()
 List of supported data types by the drag source. More...
 
Object getDragDataAs (String type)
 Drag data in a specific format or null if not supported. More...
 
Widget getDragSource ()
 Drag source. More...
 
Widget getDragTarget ()
 Current target. More...
 
void mouseMove (MouseEvent event)
 Process mouse move event. More...
 
DefaultDragAndDrop new (Widget source)
 Create default drag and drop. More...
 
void setCanDrop (bool canDrop)
 Set if dropping is possible at the current location. More...
 
void setDataTypes (DNDTypeList list)
 Set list of supported data types. More...
 
bool supportsDataType (String type)
 Drag source supports a type. More...
 

Protected Member Functions

void onCanDropChanged ()
 Can drop changed. More...
 
void onDragFinished ()
 Drag finished. More...
 
void onDropFinished ()
 Drop finished. More...
 
void onDropTargetChanged ()
 Drop target changed. More...
 

Detailed Description

Default implementation of DragAndDrop.

Provides support to do conveniently drag and drop operations. Subclass to use. Call beginDrag to start a drag and drop operation with a specific mouse button to track to end the drag operation. This grabs the mouse and keyboard on the widget used during constructing the object and adds a temporary mouse listener to track events. While tracking events the drop target can alter the can drop status. To react to these changes overwrite onCanDropChanged() and check getCanDrop(). Upon receiving mouse button release event matching the requested mouse button endDrag() is called. Drag can be cancelled any time by calling endDrag with abort set to true. The endDrag() call removes the temporary mouse listener and notifies the drop target if getCanDrop() is true. To react to this event overwrite onDragFinished(). The drop target then calls getDragDataAs() to retrieve the data. Overwrite getDragDataAs() to provide the data in the desired format if possible. Once processed the drop target calls dropDone() to indicate drop having finished. This can be any time later in case the drop target needs a longer time to finish. Once dropDone() is called onDropFinished() is called which marks the end of the drag and drop operation.

Todo:

Also add support to manage an optional semi-transparent WindowPopup widget with a drag image inside. If used the window has to be placed at the right offset underneath the parent desktop mouse pointer. The window position is update when mouse events are received. This replaces the removed DragMousePointer class.

Member Function Documentation

◆ addSupportedDataType()

void Dragengine.Gui.DefaultDragAndDrop.addSupportedDataType ( String  type)

Add supported drag type.

◆ beginDrag()

void Dragengine.Gui.DefaultDragAndDrop.beginDrag ( int  mouseButton)

Begin drag and drop operation.

Indicate mouse button tracked to end drag operation.

◆ dropDone()

void Dragengine.Gui.DefaultDragAndDrop.dropDone ( bool  success)

Drop has been processed.

Called by the drop target to signal it has finished processing the data. The drag and drop operation is finished after this call.

Implements Dragengine.Gui.DragAndDrop.

◆ endDrag()

void Dragengine.Gui.DefaultDragAndDrop.endDrag ( bool  abord)

End drag and drop operation.

Called by TrackDragListener.

◆ getCanDrop()

bool Dragengine.Gui.DefaultDragAndDrop.getCanDrop ( )

Drop action is valid on the target.

◆ getDataTypes()

DNDTypeList Dragengine.Gui.DefaultDragAndDrop.getDataTypes ( )

List of supported data types by the drag source.

Do not modify this unless you are the owner. If you need to modify this list create a copy first.

Implements Dragengine.Gui.DragAndDrop.

◆ getDragDataAs()

Object Dragengine.Gui.DefaultDragAndDrop.getDragDataAs ( String  type)

Drag data in a specific format or null if not supported.

Overwrite in subclass to provided data in the appropriate format if possible.

Implements Dragengine.Gui.DragAndDrop.

◆ getDragSource()

Widget Dragengine.Gui.DefaultDragAndDrop.getDragSource ( )

Drag source.

Implements Dragengine.Gui.DragAndDrop.

◆ getDragTarget()

Widget Dragengine.Gui.DefaultDragAndDrop.getDragTarget ( )

Current target.

◆ mouseMove()

void Dragengine.Gui.DefaultDragAndDrop.mouseMove ( MouseEvent  event)

Process mouse move event.

Called by TrackDragListener.

◆ new()

DefaultDragAndDrop Dragengine.Gui.DefaultDragAndDrop.new ( Widget  source)

Create default drag and drop.

◆ onCanDropChanged()

void Dragengine.Gui.DefaultDragAndDrop.onCanDropChanged ( )
protected

Can drop changed.

◆ onDragFinished()

void Dragengine.Gui.DefaultDragAndDrop.onDragFinished ( )
protected

Drag finished.

◆ onDropFinished()

void Dragengine.Gui.DefaultDragAndDrop.onDropFinished ( )
protected

Drop finished.

◆ onDropTargetChanged()

void Dragengine.Gui.DefaultDragAndDrop.onDropTargetChanged ( )
protected

Drop target changed.

◆ setCanDrop()

void Dragengine.Gui.DefaultDragAndDrop.setCanDrop ( bool  canDrop)

Set if dropping is possible at the current location.

Implements Dragengine.Gui.DragAndDrop.

◆ setDataTypes()

void Dragengine.Gui.DefaultDragAndDrop.setDataTypes ( DNDTypeList  list)

Set list of supported data types.

◆ supportsDataType()

bool Dragengine.Gui.DefaultDragAndDrop.supportsDataType ( String  type)

Drag source supports a type.

Implements Dragengine.Gui.DragAndDrop.


The documentation for this class was generated from the following file: