Overview
TeeTree provides built-in drag and drop functionality that allows users to reorganize nodes by dragging them to new positions within the same tree or between different trees.Basic Drag and Drop
Enable Automatic Drag and Drop
The simplest way to enable drag and drop:Toggle Drag and Drop
Drag and Drop Between Trees
TeeTree supports dragging nodes between different tree controls:Drag and Drop Properties
ToOtherTree
Allows dragging nodes from this tree to another tree:FromOtherTree
Allows accepting nodes dragged from another tree:DragRoots
Allows dragging root nodes (nodes without parents):DragToRoot
Allows dropping nodes at the root level:Complete Multi-Tree Example
Here’s a complete example with two trees and checkboxes to control drag and drop options:User Experience
When drag and drop is enabled, users can:- Click and hold on a node to start dragging
- Move the mouse to see a preview of where the node will be dropped
- Release the mouse to drop the node at the new location
- Drop on a node to make it a child of that node
- Drop between nodes to reorder siblings
- Drop on empty space to create a root node (if
DragToRootis enabled)
Visual Feedback
TeeTree provides visual feedback during drag and drop:- The dragged node is highlighted
- The target drop location is indicated
- Invalid drop locations are shown differently
- A preview of the node follows the cursor
Restrictions
By default, drag and drop has these restrictions:- Root nodes cannot be dragged (unless
DragRootsis enabled) - Nodes cannot be dropped as root nodes (unless
DragToRootis enabled) - Nodes cannot be dragged to other trees (unless
ToOtherTreeis enabled) - Nodes cannot be received from other trees (unless
FromOtherTreeis enabled) - A node cannot be dragged onto itself or its descendants
Key Points
- Set
DragAndDrop.Automatic := Trueto enable basic drag and drop - Use
ToOtherTreeandFromOtherTreefor multi-tree scenarios - Use
DragRootsto allow dragging root nodes - Use
DragToRootto allow creating new root nodes via drag and drop - TeeTree automatically prevents invalid operations (like dropping a node onto itself)
- Visual feedback guides users during drag and drop operations
- All drag and drop properties can be changed at runtime
