This class represents a target for a drag and drop operation.
A wx.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, wx.DropSource, wx.TextDropTarget, wx.FileDropTarget, wx.DataFormat, wx.DataObject
__init__ |
Constructor. |
GetData |
This method may only be called from within OnData . |
GetDataObject |
Returns the data wx.DataObject associated with the drop target. |
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 wx.DataObject associated with the drop target and deletes any previously associated data object. |
SetDefaultAction |
Sets the default action for drag and drop. |
Data |
See GetData |
DataObject |
See GetDataObject and SetDataObject |
DefaultAction |
See GetDefaultAction and SetDefaultAction |
wx.
DropTarget
(object)¶Possible constructors:
DropTarget(data=None)
This class represents a target for a drag and drop operation.
__init__
(self, data=None)¶Constructor.
data is the data to be associated with the drop target.
Parameters: | data (wx.DataObject) – |
---|
GetData
(self)¶This method may only be called from within OnData
.
By default, this method copies the data from the drop source to the wx.DataObject associated with this drop target, calling its wx.DataObject.SetData
method.
Return type: | bool |
---|
GetDataObject
(self)¶Returns the data wx.DataObject associated with the drop target.
Return type: | wx.DataObject |
---|
GetDefaultAction
(self)¶Returns default action for drag and drop or DragNone if this not specified.
Return type: | wx.DragResult |
---|
OnData
(self, x, y, defResult)¶Called after OnDrop
returns True
.
By default this will usually GetData
and will return the suggested default value defResult.
Parameters: |
|
---|---|
Return type: |
OnDragOver
(self, x, y, defResult)¶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. |
OnDrop
(self, x, y)¶Called when the user drops a data object on the target.
Return False
to veto the operation.
Parameters: |
|
---|---|
Return type: | bool |
Returns: |
|
OnEnter
(self, x, y, defResult)¶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. |
OnLeave
(self)¶Called when the mouse leaves the drop target.
SetDataObject
(self, data)¶Sets the data wx.DataObject associated with the drop target and deletes any previously associated data object.
Parameters: | data (wx.DataObject) – |
---|
SetDefaultAction
(self, action)¶Sets the default action for drag and drop.
Use DragMove or DragCopy to set default action to move or copy and use DragNone (default) to set default action specified by initialization of draging (see wx.DropSource.DoDragDrop
)
Parameters: | action (DragResult) – |
---|
DataObject
¶See GetDataObject
and SetDataObject
DefaultAction
¶See GetDefaultAction
and SetDefaultAction