BeginDrag Method

Class

ListBox, ListView, and TreeView.

Action

Presses a mouse button on an object and begins a drag operation on a listview, treeview, or list box.

Availability

This functionality is supported only if you are using the Classic Agent.

Windows operating systems.

Syntax

object.BeginDrag(iButton,
Item [, iShiftkeys])
Variable Description
iButton The mouse button to press: Windows: 1 for left, 2 for right, and 3 for center. INTEGER.
Item Identifiable object. STRING or INTEGER.
iShiftkeys Optional. Specifies one or more shift keys to hold down before beginning the drag operation. The value is interpreted as a bit mask: 1 = Alt key, 2 = Ctrl key, and 4 = Shift key. Default is 0 (no shift keys). INTEGER.

Notes

  • The BeginDrag method drags objects from logical locations, that is, objects that are identifiable. The drag operation can occur between different windows and different applications.
  • The BeginDrag method must be paired with an EndDrag or EndDragAt operation.
  • The values of iShiftkeys can be combined to specify multiple shift keys. The value of iShiftKeys can range from 0 (no shift keys) to 7 (Alt, Ctrl, and Shift). For example, specify 3 to represent the Alt and Ctrl keys.
  • Use care when recording a drag-and-drop operation. That is, do the test case setup carefully and while recording, avoid extraneous mouse movements.
  • The methods BeginDrag and EndDrag are not available in the ListViewEx class, which is the equivalent of the ListView class on the Open Agent. To achieve the same functionality on the Open Agent, use the methods PressMouse and ReleaseMouse of the AnyWin class. For example:
    MainWin("Exploring*").ListView("Contents of 'C:\test'").PressMouse (MB_LEFT, 1, 1)
    MainWin("Exploring*").ListView("Contents of 'C:\test'").ReleaseMouse (MB_LEFT, 3, 3)

Example

The following example illustrates the use of BeginDrag and EndDrag to move the file Test.t from one Microsoft Explorer window (listview) to the Testing folder in another window (treeview).
MainWin("Exploring*").ListView("Contents of 'C:\test'").BeginDrag (1, "Test.t") 

MainWin("Exploring*").TreeView("AllFolders").EndDrag ("/Desktop/My Computer/ (
C:)/Windows/Personal/Testing")