Drag and Drop Behavior

Drag and drop behavior enables the user to select an object and drag it to another location with the mouse. When the mouse button is released, the selected object is copied, moved, or linked to by a shortcut.

Uniface provides the following mechanisms for implementing drag and drop behavior in desktop applications:

  • Drag-and-Drop widgets specify that a component field can be used as a source or target for drag and drop behavior. For more information, see udragdrop.
  • Drag and Drop Formats for use by Tree and Picture widgets define the allowed actions, default action, pop-up menu options for drag and drop behavior. For more information, see Drag-and-Drop Formats.
  • Properties of tree widgets and picture widgets to specify which drag-and-drop formats to use.
  • Interactive triggers for tree and picture widgets to specify the drag and drop actions themselves, and use the drag-and-drop formats as parameters.

Uniface supports drag-and-drop behavior for drag-and-drop widgets, and for tree and picture widgets. However, the way that drag and drop behavior is implemented in these widgets is different.

A drag-and-drop widget can be defined as a source, a target, or both. It is possible to drag objects from other Uniface applications and from Microsoft Windows Explorer, as long as the target can accept the object held by the source. However, it is not possible to drag an object from a drag-and-drop widget to a tree or picture widget (or vice versa).

Tree and picture widgets use drag-and-drop formats to define the default and allowed actions for dragging and dropping objects, and interactive triggers to program the behavior. Therefore, it is possible to drag an object from a tree to a picture widget (or a tree to a tree, or a picture to a picture), but not to a drag-and-drop widget.

Drag and Drop Behavior for Tree and Picture Widgets

For tree and picture widgets, an object that can be dragged and dropped (the drag source) must have one or more supported drag formats. The location where the drag source is dropped (the drag target) must have one or more drop formats that match the drag source's format.

When a user drags from a valid drag source, the following sequence of events occurs:

  1. When the user starts to drag, the detail trigger of the drag source is executed. A possible use for this would be to collect key fields of an occurrence.

  2. When the user drags an object over a valid drop target, Uniface determines which drop format to use.

    It enumerates the list of formats specified for the drop target and selects the first format that is also defined for the dragged object. If no matching format is found, the object cannot be dropped. The icon for the matching format is shown together with the mouse pointer.

    When a drop action takes place, the relevant interactive triggers are fired for the widget, once for each selected object.

  3. When the user releases the mouse button over a valid drop target, the interactive trigger for the default drop action is executed.

    The user can override the default action by dragging with the right mouse button and selecting the desired option from the pop-up menu, or by using the Ctrl or Shift buttons with the left mouse depressed—Ctrl+Mouse (Copy), Shift+Mouse (Move), Shift+Ctrl+Mouse (Create Shortcut).

Related Topics