This class represents a target for a drag and drop operation.
A DataObject can be associated with it and by default, this object will be filled with the data from the drag source, if the data formats supported by the data object match the drag source data format.
There are various virtual handler functions defined in this class which may be overridden to give visual feedback or react in a more fine-tuned way, e.g. by not accepting data on the whole window area, but only a small portion of it. The normal sequence of calls is OnEnter, OnDragOver possibly many times, OnDrop and finally OnData.
See also
Drag and Drop Overview, DataObject Overview, DropSource, TextDropTarget, FileDropTarget, DataFormat, DataObject
__init__ | Constructor. |
GetData | This method may only be called from within OnData . |
GetDefaultAction | Returns default action for drag and drop or DragNone if this not specified. |
OnData | Called after OnDrop returns True. |
OnDragOver | Called when the mouse is being dragged over the drop target. |
OnDrop | Called when the user drops a data object on the target. |
OnEnter | Called when the mouse enters the drop target. |
OnLeave | Called when the mouse leaves the drop target. |
SetDataObject | Sets the data DataObject associated with the drop target and deletes any previously associated data object. |
SetDefaultAction | Sets the default action for drag and drop. |
This class represents a target for a drag and drop operation.
Possible constructors:
DropTarget(data=None)
Constructor.
data is the data to be associated with the drop target.
Parameters: | data (DataObject) – |
---|
This method may only be called from within OnData .
By default, this method copies the data from the drop source to the DataObject associated with this drop target, calling its DataObject.SetData method.
Return type: | bool |
---|
Returns default action for drag and drop or DragNone if this not specified.
Return type: | DragResult |
---|
Called after OnDrop returns True.
By default this will usually GetData and will return the suggested default value defResult.
Parameters: |
|
---|---|
Return type: |
Called when the mouse is being dragged over the drop target.
By default, this calls functions return the suggested return value defResult.
Parameters: |
|
---|---|
Return type: | |
Returns: | The desired operation or DragNone. This is used for optical feedback from the side of the drop source, typically in form of changing the icon. |
Called when the user drops a data object on the target.
Return False to veto the operation.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True to accept the data, or False to veto the operation. |
Called when the mouse enters the drop target.
By default, this calls OnDragOver .
Parameters: |
|
---|---|
Return type: | |
Returns: | The desired operation or DragNone. This is used for optical feedback from the side of the drop source, typically in form of changing the icon. |
Called when the mouse leaves the drop target.
Sets the data DataObject associated with the drop target and deletes any previously associated data object.
Parameters: | data (DataObject) – |
---|
Sets the default action for drag and drop.
Use DragMove or DragCopy to set deafult action to move or copy and use DragNone (default) to set default action specified by initialization of draging (see DropSource.DoDragDrop )
Parameters: | action (DragResult) – |
---|
See GetDefaultAction and SetDefaultAction