Performing Drag-and-Drop or Copy/Cut/Paste

If you enable the functionality, users can affect the tree structure by adding, moving, and deleting nodes. In Windows environments, users accomplish these tasks with drag-and-drop functions. In Web environments, users accomplish these tasks with copy/cut/paste.

When you place the control on a form initially, all three options are enabled:

  • Cut (drag-and-drop move).

  • Copy.

  • Cut-copy-paste (drag-and-drop).

You can disable these options at design time. When an option is enabled and a user attempts the operation, the cursor indicates that the function is not permitted, and none of the associated events execute. You can control operations to the database using these events:

  • Tree - Begin Drag/Cut/Copy

    If you enable any of the three operations, the Begin Drag event fires, and the drag mode is set to Move for the first two operations (cut or copy). The mode is set to Copy for the third operation (cut-copy-paste).

  • Tree - Drag Over Node

    You can attach ER to this event to verify that the node on which the dragged record is about to be dropped is a valid situation. If it is not, you can use a system function to change the cursor to a No Drop cursor to indicate that dropping the record there is not permitted. If the cursor is not the No Drop cursor, when the record is dropped the event, Tree - End Drag Drop/Paste, runs. The same is true of cut-and-paste or copy-and-paste operations.

  • Tree - End Drag Drop/Paste

    You can attach ER to this event to update or insert information that has been moved or copied using the drag. Be aware of the effect of using Insert Grid Buffer Row in the Tree -End Drag Drop/Paste event, as well as deleting the grid row dragged if the mode is a move.

  • Tree - Cancel Drag Drop/Paste

    No matter the operation, if the user cancels, then this event occurs.

In addition to drag-and-drop or copy/cut/paste, users (and applications) can simply move nodes up and down or change their hierarchical level (indent and outdent). These events are provided in connection with these activities:

  • Node Move Up Verify Before

    When an attempt to move a node up occurs, runtime fires this event. If the system function, Suppress Node Move Up/Down is called within this event, then move up is canceled. Otherwise, runtime moves the node upwards one position and then fires the event, Node is Moved Up.

  • Node Is Moved Up

    When a node has been moved up by one position (if permitted on the event, Node Move Up Verify Before), then the event, Node is Moved Up, is fired for that node. Its child nodes are still parented to the moved node. You cannot move a node that is the first node on its level up.

  • Node Move Down Verify Before

    When an attempt to move a node down occurs, runtime fires this event. If the system function, Suppress Node Move Up/Down is called within this event, then move down is canceled. Otherwise, runtime moves the node downwards one position and then fires the event, Node is Moved Down.

  • Node Is Moved Down

    When a node has been moved down by one position (if permitted on the event, Node Move Down Verify Before), then the event, Node is Moved Down, is fired for that node. Its child nodes are still parented to the moved node. You cannot move a node that is the last node on its level down.

  • Node Indent Verify Before

    When an attempt to indent a node occurs, runtime fires this event. If the system function, Suppress Node Indent/Outdent, is called within this event, then indent is canceled. Otherwise, runtime demotes the node to be a child of its previous sibling (the demoted node remains the parent of its children). Then the event, Tree Node is Indented, is fired.

  • Tree Node is Indented

    When a node has been indented (if permitted on the event, Node Indent Verify Before), then the event, Tree Node is Indented, is fired for that node. Its child nodes are still parented to the indented node. The application must update the node's internal data to reflect its new parent. You cannot indent a node that is the first node on its level.

  • Node Outdent Verify Before

    When an attempt to outdent a node occurs, runtime fires this event. If the system function, Suppress Node Indent/Outdent, is called within this event, then outdent is canceled. Otherwise, runtime promotes the node to be a parent of the sibling beneath it. The original parent becomes the sibling of the outdented node. If the outdented node is the first child, then the original parent loses all of its children to the outdented node and becomes a leaf node. The child nodes of the outdented nodes are otherwise unaffected. Then the event, Tree Node is Outdented, is fired.

  • Tree Node is Outdented

    When a node has been outdented (if permitted on the event, Node Outdent Verify Before), then the event, Tree Node is Outdented, is fired for that node. The application must update the node's internal data to reflect its new parent.

  • Tree Node Bitmap is Clicked

    Under most conditions, each node in the tree has a bitmap next to it for display purposes only. You can use Set Tree Node Clickable Bitmap to provide an additional bitmap which is clickable; that is, clicking the bitmap causes the event, Tree Node Bitmap is Clicked, to fire.