************* wx.DropTarget ************* Inheritance diagram for `wx.DropTarget`: | .. inheritance-diagram:: wx.DropTarget | Description =========== 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 <#OnEnter>`_, possibly many times `OnDragOver <#OnDragOver>`_, `OnDrop <#OnDrop>`_. The return values of most of the DnD operations, termed `wx.DragResult`, can be sketched as follows: ================================== ============================================ Flag Description ================================== ============================================ ``wx.DragError`` Error prevented the d&d operation from completing ``wx.DragNone`` Drag target didn't accept the data ``wx.DragCopy`` The data was successfully copied ``wx.DragMove`` The data was successfully moved (MSW only) ``wx.DragLink`` Operation is a drag-link ``wx.DragCancel`` The operation was cancelled by user (not an error) ================================== ============================================ .. seealso:: `wx.DropSource `_, `wx.TextDropTarget `_, `wx.FileDropTarget `_, `wx.DataFormat `_, `wx.DataObject `_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.FileDropTarget `_, `wx.PyDropTarget `_, `wx.TextDropTarget `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `GetData <#GetData>`_ * `OnDrop <#OnDrop>`_ * `OnEnter <#OnEnter>`_ * `OnDragOver <#OnDragOver>`_ * `OnLeave <#OnLeave>`_ * `SetDataObject <#SetDataObject>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(dataObject=None) Constructor. **Parameters:** * `dataObject` (`wx.DataObject `_): the data to associate with the `wx.DropTarget`. | **Returns:** `wx.DropTarget `_ -------- .. method:: GetData() By default, this method copies the data from the drop source to the `wx.DataObject` associated with this drop target, calling its `SetDataObject <#SetDataObject>`_ method. | **Returns:** `bool` -------- .. method:: OnDrop(x, y) Called when the user drops a data object on the target. Return ``False`` to veto the operation. **Parameters:** * `x` (int): The x coordinate of the mouse. * `y` (int): The y coordinate of the mouse. | **Returns:** `bool` -------- .. method:: OnEnter(x, y, default) Called when the mouse enters the drop target. By default, this calls `OnDragOver <#OnDragOver>`_. **Parameters:** * `x` (int): The x coordinate of the mouse. * `y` (int): The y coordinate of the mouse. * `default` (int): Suggested default for return value. Determined by ``SHIFT`` or ``CONTROL`` key states. | **Returns:** `int` -------- .. method:: OnDragOver(x, y, default) Called when the mouse is being dragged over the drop target. By default, this calls functions return the suggested return value `default`. **Parameters:** * `x` (int): The x coordinate of the mouse. * `y` (int): The y coordinate of the mouse. * `default` (int): Suggested default for return value. Determined by ``SHIFT`` or ``CONTROL`` key states. | **Returns:** `bool` -------- .. method:: OnLeave() Called when the mouse leaves the drop target. -------- .. method:: SetDataObject(data) Sets the data `wx.DataObject` associated with the drop target and deletes any previously associated data object. **Parameters:** * `wx.DataObject `_