Drag-and-drop properties, events, and functions

Drag-and-drop properties

Each PowerBuilder control has two drag-and-drop properties:

The DragAuto property DragAuto is a boolean property.

Table 10-1: DragAuto property values

Value

Meaning

TRUE

When the object is clicked, the control is placed automatically in drag mode

FALSE

When the object is clicked, the control is not placed automatically in drag mode; you have to put the object in drag mode manually by using the Drag function in a script

StepsTo specify automatic drag mode for a control in the Window painter:

  1. Select the Other property page in the Properties view for the control.

  2. Check the Drag Auto check box.

The DragIcon property Use the DragIcon property to specify the icon you want displayed when the control is in drag mode. The DragIcon property is a stock icon or a string identifying the file that contains the icon (the ICO file). The default icon is a box the size of the control.

When the user drags a control, the icon displays when the control is over an area in which the user can drop it (a valid drop area). When the control is over an area that is not a valid drop area (such as a window scroll bar), the No-Drop icon displays.

StepsTo specify a drag icon:

  1. Select the Other property page in the Properties view for the control.

  2. Choose the icon you want to use from the list of stock icons or use the Browse button to select an ICO file and click OK.

NoteCreating icons To create icons, use a drawing application that can save files in the Microsoft Windows ICO format.

Drag-and-drop events

There are six drag-and-drop events.

Table 10-2: Drag-and-drop events

Event

Occurs

BeginDrag

When the user presses the left mouse button in a ListView or TreeView control and begins dragging

BeginRightDrag

When the user presses the right mouse button in a ListView or TreeView control and begins dragging

DragDrop

When the hot spot of a drag icon (usually its center) is over a target (a PowerBuilder control or window to which you drag a control) and the mouse button is released

DragEnter

When the hot spot of a drag icon enters the boundaries of a target

DragLeave

When the hot spot of a drag icon leaves the boundaries of a target

DragWithin

When the hot spot of a drag icon moves within the boundaries of a target

Drag-and-drop functions

Each PowerBuilder control has two functions you can use to write scripts for drag-and-drop events.

Table 10-3: Drag-and-drop event functions

Function

Action

Drag

Starts or ends the dragging of a control

DraggedObject

Returns the control being dragged

For more information about these events and functions, see the PowerScript Reference.