DragItem.Constructor(w as Window, x as Integer, y as Integer, width as Integer, height as Integer, DragPicture as Picture)

From Xojo Documentation

Constructor
DragItem.Constructor(w as Window, x as Integer, y as Integer, width as Integer, height as Integer [,DragPicture as Picture])

Creates a new DragItem. The parameter w is the window that the drag originates from. The parameters x and y are the coordinates relative to this window. The parameters width and height are the size/bounds of the drag rectangle. If the optional DragPicture parameter is passed, it will be used instead of the default rectangle to indicate the size and shape of the dragged item during the drag.

Notes

The previous methods for creating a DragItem are deprecated: RectControl.NewDragItem and Window.NewDragItem.

Examples

The following code is from the example project "Custom Drag" in the Examples folder. The main window consists of a Label control and a TextArea. The user can drag the text in the Label into the TextArea. This is not possible by default but the ability to drag the text is enabled by the code in the MouseDown event of the Label. It is:

Var d As DragItem
d = New DragItem(Self, Me.Left, Me.Top, Me.Width, Me.Height)
d.Text = Me.Text
d.Drag

This example drags a picture. It uses the optional DragPicture property in the constructor.

Var d As DragItem
d = New DragItem(Self, X, Y, Me.Width, Me.Height, MyPicture)

d.MouseCursor = System.Cursors.HandOpen
d.AddItem(0, 0, Me.Width, Me.Height)
d.Picture = Me.Image
d.Drag // Allow the drag