[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 User's Guide



Using Drag and Drop

The drag and drop facility allows you to pick up an object from one part of your display and move it to a new location. The object you pick up is called the drag source. The location where you drop it is called the drop site.

With drag and drop, you can do the following tasks:

  1. Move text or other information between windows (cut and paste)

  2. Invoke actions

  3. Obtain information about drop sites

    For example, you can print the contents of a file by dragging an icon representing the file and dropping it on an icon representing a printer.

    The source and destination of the drop can both be in the same application, or they can be in different applications. Text components, Labels, Menus, and Lists are drag sources in all Motif applications. Text components are also automatically drop sites. Other drag sources and drop sites are defined by the specific applications.

    Additionally, the contents of Labels and Scales may be draggable.

  4. Starting a Drag

    To start a drag:

    1. Decide what you want to drag, and select it as follows:

      1. For Text components, select the text to be dragged.

      2. For Lists, if you want to drag several items, select them. A single item can be dragged without first being selected.

      3. Other items usually can be dragged without being selected first; however, applications may require you to select single items before dragging them.

      4. Move the pointer to the item that you want to drag. This item is the drag source.

      5. Press and hold down Button 2.

      6. Specify the operation that you want to happen when the drop is made by pressing modifier keys on your keyboard (see Table 3-1).

        Table 7. Drag Operations

        Key Action
        Shift Move; information is moved from the initiator to the receiver
        Ctrl Copy; information is copied from the initiator to the receiver
        Shift Ctrl Link; information is linked from the initiator to the receiver

        If a modifier key is not pressed, a move operation is generally assumed, but the actual operation chosen depends on the source and destination. The applications that are controlling the source and destination may have specified that only some of the possible operations are allowed. A move operation deletes the information from the original location after it has been copied to the new location.

        Note that which mouse buttons are to be used for transfer depends on how these buttons have been defined for your mouse. In some cases, Button 1 is used to both select and transfer the data and Button 2 is used to adjust or extend the selection and for primary transfer, and in other cases, Button 1 is used to select the text, and Button 2 is used to transfer it. This extension of the capabilities of Button 1 and Button 2 is possible for Text, Lists, and Containers.

        If the system selects an operation that you do not want, press the appropriate modifier keys to change to a new operation at any time during the drag.

        A drag icon representing the drag source appears instead of the normal pointer. The drag icon used depends on the drag source. The drag icon consists of three parts:

        1. Source Icon: The source icon is a graphical representation of the object being dragged.

        2. State Icon: The state icon represents the relation of the drag icon to what is under it. It may change depending on whether the drag icon is over a valid drop site, over an invalid drop site, or not over a drop site.

        3. Operation Icon: The operation icon represents the operation to be performed when the drop is made (copy, move, or link). If you have requested an operation that either the initiator or receiver does not allow, this icon will be blank.

          Figure 3-30 shows a drag icon. The source icon is the running figure, the state icon is the arrow in the upper left corner, and the operation icon is the box just below the arrow.

          Figure 32. A Drag Icon.




          View figure.

          Motif defines a default source icon for textual information, which is used if the drag source is a List, a Label, or a Text component. If the source is a graphics component, Motif will attempt to use the graphic image as the source icon. If the source is of a different type and the application has not provided a source icon for that type of data, the running figure is used as the source icon.

          The state and operation icons are optional in a drag icon. Motif provides default operation icons for move, copy, and link operations. The default state icon for all three states is an arrow in the upper left corner of the drag icon.

          Figure 3-31 shows the default drag icons for graphics and textual information for move, copy, and link operations.

          Figure 33. Default Drag Icons.




          View figure.

          An application can specify different icons for each of the operations and states, as well as arrange the icons in a different way than the one shown in the illustration. You can also specify different icons by setting resources (see Chapter 7).

        4. During the Drag

          Without releasing the mouse button, move the mouse around. The drag icon representing the source moves around the screen instead of the normal pointer shape. A drag can also be operated from the keyboard, usually with one of the arrow keys.

          Every drag icon has a hot spot. The whole icon is considered in or out of a drop site when the hot spot is in or out of the drop site. If a drag icon displays a state icon, the hot spot is in it. Otherwise, the hot spot is in the source icon. The hot spot in the default state icon is located at the point of the arrow.

          As the drag icon moves around the screen, it may change color or shape to indicate whether the drag icon is over a valid drop site, an invalid drop site, or no drop site. These changes are called drag-over effects. The default behavior is that there is no apparent change during the move. However, an application may provide other drag-over effects or you can specify your own with resources.

          The operation icon indicates which operation will occur when the drop is made. You can change modifier keys to switch the operation at any time during a drag. The operation icon will change to show the new operation. If you have not specified an operation using the modifier keys, the default operation depends on what drop site the drag icon is over.

          The appearance of a drop site may also change as the drag icon moves in and out of it. These changes are called drag-under effects. The default drag-under effect for a valid drop site is to display a border around the drop site. Another common drag-under effect is called pause drag. This is where the drag icon is held over an area (without releasing) with some action resulting in the area underneath. A scrolled window, for example, might scroll if the drag icon is paused on the scroll arrows, or at the border of the window. Other drag-under effects depend on the application that is controlling the drop site.

          Dropping on a Destination

          To drop a dragged object on a destination:

          1. Move the drag icon over a drop site.

          2. Release Button 2 while still pressing any modifier keys that you are using to determine the operation. The drag operation can also be completed from the keyboard, usually by pressing osfActivate or <Enter>.

            If the drop site is valid for that drag source, then the drag icon shows the completed drop by melting into the destination. If the drop site is not valid for that drag source, then the drag icon snaps back to the point from where the drag was initiated.

            If the drag source is a Label, a List, or a Text component, the data being dragged is textual information and can be dropped on any Text destination. Other combinations of source type and destination type are defined by the application.

            If the destination holds data or information, the dragged information generally is inserted at the pointer location. If the destination represents an application or device, generally a drop starts some action. What the action is depends on the application. For instance, if you drag an icon representing a file to an icon representing a printer, then the action will be that the contents of that file are printed on the printer indicated by the icon.

          3. Getting Help

            You can request help about a particular drop site if the application has provided help information. The help information usually explains the sources that are expected by a drop site and the actions that will occur as a result of a drop.

            To request help:

            1. Move the drag icon over a drop site.

            2. Press Help or F1.

              Figure 3-32 shows an example of Help information.

              Figure 34. Help Information.




              View figure.

            3. Canceling a Drag

              At any time during a drag, you can cancel the drag operation. To cancel a drag in progress, press Cancel. The drag icon is replaced by the normal pointer shape and any special drag-over and drag-under effects go away.


              [ Previous | Next | Contents | Glossary | Home | Search ]