Process Flow of a Drag and Drop Operation

Use

The process flow of a drag and drop operation is described below. The role of the application server and the front end is also explained. The single steps that have to be made in an application program so that drag and drop can be used derive from this workflow.

Process

Application Server

  1. You create the custom control.

  2. You register the drag and drop events.

  3. You define the drag and drop behavior for the individual custom controls or their components. To do this, you create an instance of the class CL_DRAGDROP. You then assign one or more flavors to this instance using the method add. These describe the drag and drop behavior of the relevant custom control. You can still change the flavors during the program flow (method modify), delete (method remove) and query (method get). You can also initialize whole instances (method clear) or destroy them (method destroy)

  4. You assign flavors to the Custom Control using control-specific methods. For further information, refer to the corresponding control documentation.

Front End

The following steps are performed by the system at the front end. They are only listed here so that you can understand what happens during a drag and drop operation.

  1. Once the use has selected an object with the left mouse button, the drag and drop service starts.

  2. The drag and drop service checks whether a drag and drop behavior has been defined for the object, and whether the object can be dragged (DragSource attribute).

  3. If the DragSource attribute was set, drag and drop is started. The mouse pointer changes automatically.

  4. As long as the left mouse button remains pressed, the system continually checks whether the mouse pointer is positioned over an object in a custom control that can receive a dropped object (DropTarget attribute), and whether the flavor of that object is the same as the flavor of the source. If this is the case, the mouse pointer changes again to inform the user.

  5. If the user now drops the object, an event is triggered to inform the application server.

Application server

  1. The drag and drop service of the application server creates an instance of the class CL_DRAGDROPOBJECT. You can use this instance (for example, drag_drop_object) in all events of the drag and drop process as an event parameter. You can use it to find out the context between the events.

  2. The drag and drop service checks whether the drag object and drop object have more than one flavor in common. If this is the case, the event ONGETFLAVOR is triggered. In the corresponding handler method, you must decide which flavor to use. You do this using the method set_flavor.

  3. Now, the drag and drop event ONDRAG is triggered. It has event parameters that tell you which object the user has dragged. Within the handler routine, you must pass the context (information about the source object) to the instance of the drag and drop data object created. drag_drop_object->object = mydragobject.

  4. Next, the ONDROP event is triggered. The corresponding handler method serves to process the drag and drop data object. Here, you have to implement the changes that are to be made to the target object based on the drag and drop operation.

  5. The last event of the drag and drop operation is ONDROPCOMPLETE. This is where you can make your last changes to the drag and drop object. In particular, you should use this event to delete the source object from the DragSource control and the corresponding data structures if you have used the drag and drop operation to move the object.