Show TOC

Drag and Drop EventsLocate this document in the navigation structure

Use

This section only describes those properties of drag and drop events that apply to all controls. The individual control wrappers may augment them. You should therefore consult the relevant control documentation to see if that control has any peculiarities.

There are four standard events in a drag and drop operation at which control is returned to the application program. You use the event handler methods for these events to implement the actions that should be performed during the operation.

Note

Some control wrappers offer additional drag and drop events. For further information, refer to the documentation of the individual controls.

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 wrapper of the control that you are using.

However, you still have to specify handler methods for the events.

  • DATA tree TYPE REF TO cl_gui_simple_tree.

  • SET HANDLER dragdrop=>on_drag FOR tree.

The events are always registered as system events.

Features

In a drag and drop operation, the Control Framework does not pass any events to the application server until the object is dropped. At the application server, it is separated into up to four standard events that can occur within a drag and drop operation, as described in Process Flow of a Drag and Drop Operation. All events have a drag and drop data object as an event parameter. You use this parameter to manage the context of the drag and drop operation. The particular control wrapper that you are using also provides further information about the drag and drop context. For further information, refer to the documentation of the relevant control wrapper.

  • ONGETFLAVOR: This event is triggered only if the source object and the target object have several common flavors. In the handler method, you must then specify which flavor should be used. To do this, use the set_flavor method on the drag and drop object. The event is triggered by the target object of the drag-and-drop operation.

  • ONDRAG: This event is always triggered when the drag and drop operation is complete at the front end. When you handle this event, you must determine the context of the target object. You then pass this context to the instance of the class CL_DRAGDROPOBJECT that you received as an event parameter. The event is triggered by the source object of the drag and drop operation.

  • ONDROP: When you handle this event, you define what should be done to the target object. Here you use the event parameter for the context that you have filled for the event ONDRAG. Note the following in connection with this event:

    • Within the ONDROP event, you must make a dynamic typecast. You must catch all possible exceptions of the typecast. In the exception handling you must include handling for the case where you try to assign an invalid object. In this case, you must use the abort method to terminate the drag-and-drop operation.

    • You should select the flavor you want to use so that it is possible to assign the drag-and-drop object to the right TypeCast.

    The event is triggered by the target object of the drag-and-drop operation.

  • ONDROPCOMPLETE: Use this event to perform any further processing necessary after the end of the drag-and-drop operation. For example, this would be necessary following a move operation. The event is triggered by the source object of the drag-and-drop operation.