Defining Drag and Drop Events in the SAP Tree
Use
This section explains the special considerations that apply to drag and drop operations in the SAP Tree.
Prerequisites
To be able to react to an event, you must first register it. Unlike normal event handling, you do not register drag and drop events with the Control Framework using the set_registered_events method. Instead, they are registered automatically by the SAP Tree control wrapper.
However, you still have to specify handler methods for the events.
The events are always registered as system events.
When you fill the node table, you must also specify which nodes are enabled for drag and drop, and the flavors that the nodes should have. You do this by assigning the relevant drag and drop behavior to the field in the node table (see point 3 under Drag and Drop Operations). This requires the following steps (see also the Drag and Drop Programming Example):
-
Define the drag and drop behavior:
DATA behaviour_left TYPE REF TO cl_dragdrop. CREATE OBJECT behaviour_left. CALL METHOD behaviour_left->add EXPORTING flavor = 'Tree_move_to_Edit' dragsrc = 'X' droptarget = ' ' effect = cl_dragdrop=>copy.
-
Use the get_handle method to return a handle to the drag and drop behavior:
CALL METHOD behaviour_left->get_handle IMPORTING handle = handle_tree.
-
Assign the handle to the DRAGDROPID field of the corresponding entry in the node table:
node-dragdropid = handle_tree. " handle of behaviour
Features
The following table contains the events used in drag and drop:
|
Event |
Description |
|
ON_DROP_GET_FLAVOR |
See the event ONGETFLAVOR under Drag and Drop Events |
|
ON_DRAG |
See the event ONDRAG under Drag and Drop Events To be used for trees without multiple selection (NODE_SELECTION_MODE = TREE->NODE_SEL_MODE_SINGLE) |
|
ON_DRAG_MULTIPLE |
See the event ONDRAG under Drag and Drop Events For trees with multiple selection (NODE_SELECTION_MODE = TREE->NODE_SEL_MODE_MULTIPLE) |
|
ON_DROP |
See the event ONDROP under Drag and Drop Events |
|
ON_DROP_COMPLETE |
See the event ONDROPCOMPLETE under Drag and Drop Events To be used for trees without multiple selection (NODE_SELECTION_MODE = TREE->NODE_SEL_MODE_SINGLE) |
|
ON_DROP_COMPLETE_MULTIPLE |
See the event ONDROPCOMPLETE under Drag and Drop Events For trees with multiple selection (NODE_SELECTION_MODE = TREE->NODE_SEL_MODE_MULTIPLE) |
The individual events have the following parameters:
|
Event |
Event Parameter |
Description |
|
ON_DROP_GET_FLAVOR |
NODE_KEY |
Technical name of the node to which the source object referred |
|
DRAG_DROP_OBJECT |
Data object for description of the source object |
|
|
FLAVORS |
Common flavors of the drag-and-drop operation |
|
|
ON_DRAG |
NODE_KEY |
Technical name of node that was selected as source object |
|
ITEM_NAME (not for Simple Tree) |
Technical name of item that was selected as the source object |
|
|
DRAG_DROP_OBJECT |
Data object for description of the source object |
|
|
ON_DRAG_MULTIPLE |
NODE_KEY_TABLE |
Table of nodes that were selected as source objects |
|
ITEM_NAME (not for Simple Tree) |
Technical name of item that was selected as the source object |
|
|
DRAG_DROP_OBJECT |
Data object for description of the source object |
|
|
ON_DROP |
NODE_KEY |
Technical name of the node to which the source object referred |
|
DRAG_DROP_OBJECT |
Data object for description of the source object |
|
|
ON_DROP_COMPLETE |
NODE_KEY |
Technical name of node that was selected as source object |
|
ITEM_NAME (not for Simple Tree) |
Technical name of item that was selected as the source object |
|
|
DRAG_DROP_OBJECT |
Data object for description of the source object |
|
|
ON_DROP_COMPLETE_MULTIPLE |
NODE_KEY_TABLE |
Table of nodes that were selected as source objects |
|
ITEM_NAME (not for Simple Tree) |
Technical name of item that was selected as the source object |
|
|
DRAG_DROP_OBJECT |
Data object for description of the source object |