.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2025 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. currentmodule:: wx.lib.mixins.treemixin

.. highlight:: python



.. _wx.lib.mixins.treemixin.DragAndDrop:

==========================================================================================================================================
|phoenix_title|  **wx.lib.mixins.treemixin.DragAndDrop**
==========================================================================================================================================

This is a mixin class that can be used to easily implement
dragging and dropping of tree items. It can be mixed in with
wx.TreeCtrl, wx.gizmos.TreeListCtrl, or wx.lib.customtree.CustomTreeCtrl.

To use it derive a new class from this class and one of the tree
controls, e.g.::

  class MyTree(DragAndDrop, wx.TreeCtrl):
      # Other code here


You *must* implement OnDrop. OnDrop is called when the user has
dropped an item on top of another item. It's up to you to decide how
to handle the drop. If you are using this mixin together with the
VirtualTree mixin, it makes sense to rearrange your underlying data
and then call RefreshItems to let the virtual tree refresh itself. 



|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div class="collabsible-wrapper">
      <input id="collapsible-inheritance" class="collapsible-checkbox" type="checkbox">
      <label for="collapsible-inheritance" tabindex="0" title="Show inheritance diagram" class="collapsible-label">Inheritance diagram for class <strong>DragAndDrop</strong>:</label>
      <div class="collapsible-content">
         <p class="graphviz">
            <center><img src="_static/images/inheritance/wx.lib.mixins.treemixin.DragAndDrop_inheritance.svg" alt="Inheritance diagram of DragAndDrop" usemap="#dummy" class="inheritance invert-in-dark-mode"/></center>
            <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.lib.mixins.treemixin.DragAndDrop.html" title="This is a mixin class that can be used to easily implement" alt="" coords="189,82,481,111"/> <area shape="rect" id="node2" href="wx.lib.mixins.treemixin.TreeAPIHarmonizer.html" title="This class attempts to hide the differences in API between the" alt="" coords="5,5,339,34"/> <area shape="rect" id="node3" href="wx.lib.mixins.treemixin.TreeHelper.html" title="This class provides methods that are not part of the API of any" alt="" coords="362,5,635,34"/> </map> 
         </p>
      </div>
   </div>
   <script type="text/javascript" src="_static/inheritancetoggle.js"></script>



|


|super_classes| Known Superclasses
==================================

:class:`wx.lib.mixins.treemixin.TreeAPIHarmonizer`, :class:`wx.lib.mixins.treemixin.TreeHelper`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.__init__`                            Initialize self.  See help(type(self)) for accurate signature.
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.IsValidDragItem`                     
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.IsValidDropTarget`                   
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.OnBeginDrag`                         
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.OnDragging`                          
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.OnDrop`                              This function must be overloaded in the derived class.
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.OnEndDrag`                           
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.ResetCursor`                         
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.SetCursorToDragging`                 
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.SetCursorToDroppingImpossible`       
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.StartDragging`                       
:meth:`~wx.lib.mixins.treemixin.DragAndDrop.StopDragging`                        
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: DragAndDrop(TreeAPIHarmonizer, TreeHelper)

   This is a mixin class that can be used to easily implement
   dragging and dropping of tree items. It can be mixed in with
   wx.TreeCtrl, wx.gizmos.TreeListCtrl, or wx.lib.customtree.CustomTreeCtrl.
   
   To use it derive a new class from this class and one of the tree
   controls, e.g.::
   
     class MyTree(DragAndDrop, wx.TreeCtrl):
         # Other code here
   
   
   You *must* implement OnDrop. OnDrop is called when the user has
   dropped an item on top of another item. It's up to you to decide how
   to handle the drop. If you are using this mixin together with the
   VirtualTree mixin, it makes sense to rearrange your underlying data
   and then call RefreshItems to let the virtual tree refresh itself. 

   .. method:: __init__(self, \*args, \*\*kwargs)

      Initialize self.  See help(type(self)) for accurate signature.


   .. method:: IsValidDragItem(self, dragItem)


   .. method:: IsValidDropTarget(self, dropTarget)


   .. method:: OnBeginDrag(self, event)


   .. method:: OnDragging(self, event)


   .. method:: OnDrop(self, dropItem, dragItem)

      This function must be overloaded in the derived class.
      dragItem is the item being dragged by the user. dropItem is the
      item dragItem is dropped upon. If the user doesn't drop dragItem
      on another item, dropItem equals the (hidden) root item of the
      tree control. 


   .. method:: OnEndDrag(self, event)


   .. method:: ResetCursor(self)


   .. method:: SetCursorToDragging(self)


   .. method:: SetCursorToDroppingImpossible(self)


   .. method:: StartDragging(self)


   .. method:: StopDragging(self)


