dragStart()

Starts a drag operation.

Synopsis

int dragStart( string information[, string pixmap =""[, int
dragType = DRAG_COPY[,
string
mimeType = "text/plain"]]);

Parameters

Parameter Description
information Information to be provided. Currently, the information must be of string data type (this means: TEXT only) otherwise the function will return -1 and an error will be shown.
pixmap

The image that is shown next to the cursor during a drag operation. An empty string uses a default image of the operating system. The passed filename must be specified relative to the <proj_path>/pictures directory. If the given filename has no extension, several options will be checked, for example, .png, .xpm, .bmp.

From the Qt documentation: The platform-specific implementation will use this where it can. Therefore, provide a small masked pixmap and do not assume that the user will actually see it. Warning: Problems can occur with drag cursors in different graphics hardware and driver software on Windows. Reducing the graphics acceleration in the display settings will solve the problems.

dragType

The "dragType" is one of the following CTRL constants which define what operation the drag object wants to realize with it:

DRAG_COPY - copies the information of the dragged object

DRAG_MOVE - moves the information of the dragged object

DRAG_LINK - links the information of the dragged object

mimeType

"mimeType" defines the type of information that will be dragged around. Since currently only TEXT values are supported, you can only use a mimeType that starts with "text/", for example, "text/plain", "text/html", etc.

For registered "text/" MIME types, see http://www.iana.org/assignments/media-types/text/.

hotSpot X

The hotspot X for the bitmap image that is shown next to the cursor during a drag operation. By using the parameters hotspot X and hotspot Y the image can be shown in the middle of the cursor. The hotspot refers to the upper left corner of a pixmap image. If the image size is, e.g. 40x60 pixels, specify the parameters 20, 30 and the image is shown in the middle of the cursor.

Hotspot X and hotspot Y can only be used together.

hotSpot Y

The hotspot Y for the bitmap image that is shown next to the cursor during a drag operation. By using the parameters hotspot X and hotspot Y the image can be shown in the middle of the cursor. The hotspot refers to the upper left corner of a pixmap image. If the image size is, e.g. 40x60 pixels, specify the parameters 20, 30 and the image is shown in the middle of the cursor.

Hotspot X and hotspot Y can only be used together.

Return Value

-1 in case of error. Otherwise 0.

Description

Starts a drag operation.

When the "Draggable" attribute is TRUE, but the user has not implemented anything in the DragStart script, no drag operation will be started.

Graphic objects inside a panel reference are an exception: These provide their dollar parameters as default drag information when they do not use the dragStart() function in the script. The dollar parameters are passed in the format $name:value\n$name:value and so on. For example:
 $DPE:Motor1.runs
                $color:green

Example

For examples on how to this function see chapter Example of Drag and Drop.

Warning: Calling dragStart() in a context where it does not make sense to start a drag operation can freeze the UI. For a drag operation to start successfully, a mouse button must be pressed (or a finger touches a touch screen) at the moment dragStart() is called. Therefore dragStart() will most likely be called in one of the following shape event scripts:
  • DragStart
  • MousePressed
  • RightMousePressed

Assignment

Graphics functions

Availability

UI