Language > Widgets > About Tree Widgets > Tree Widget Drag and Drop Examples

# Tree Widget Drag and Drop Examples

Tree widget drag and drop scenarios can range from relatively straight forward to quite complex. The degree of complexity usually increases with the inclusion of multiple selection and custom drag callbacks. Two example applications are included in the IDL distribution, illustrating simple and relatively complex drag and drop applications.

#### Simple Drag and Drop Example

The IDL distribution contains an example that creates a single selection tree that allows you to rearrange the folder and leaf nodes. The example demonstrates how to:

- Enable dragging and drop events
- Handle drop events
- Move a node in response to a drop event
  Including:
- Determining the insertion parent
- Determining the insertion index

The simple drag and drop example is included in the file `drag_and_drop_simple.pro`in the`examples/doc/widgets` subdirectory of the IDL distribution. Run this example procedure by entering `drag_and_drop_simple` at the IDL command prompt or view the file in an IDL Editor window by entering `.EDIT drag_and_drop_simple.pro`.

#### Complex Drag and Drop Example

The IDL distribution contains an example that creates three multiple selection trees and demonstrates how to:

- Handle multiple selection drags
- Create custom drag notification callbacks
- Implement control-key copying (versus simple moving)
- Implement “trigger-loaded” folders
- Enable dragging
- Enable drop events
- Copy one or more nodes in response to a drop event
  Including:
- Determining the insertion parent.
- Determining the insertion index

This example also demonstrates many of the tree widget manipulation capabilities, such as those involving node indexes and masked bitmaps,

The complex drag and drop example is included in the file `drag_and_drop_complex.pro`in the`examples/doc/widgets` subdirectory of the IDL distribution. Run this example procedure by entering `drag_and_drop_complex` at the IDL command prompt or view the file in an IDL Editor window by entering `.EDIT drag_and_drop_complex.pro`.