Sign in Join
FPDoc Onlineexperiment

TDragObject class

In unit Controls

Base class for managing drag operations and user feedback.

Declaration

pascal
TDragObject = class

Descends from it: TDragControlObject TDragDockObject TDragObjectEx

Description

Every dragging operation has an associated DragObject, holding references to the source and target controls, and other parameters for the customization of the visual user feedback.

A default DragObject is created automatically when a dragging operation starts, and is destroyed when the operation has ended; you do not need to maintain it. But an application can provide a customized DragObject in the OnStartDrag or OnStartDock handlers for the source control (the one being dragged).

AutoCreated DragObjects imply different behavior in the DragOver and DragDrop events, where the Source becomes the dragged control, while the DragObject itself is passed as Source.

TDragObject is the ancestor of a whole tree of dragging objects, with the main branches supporting either drag-drop or drag-dock operations. The type of the operation is determined using the DragKind property in the source control.

In contrast to the Delphi implementation, Lazarus has moved a couple of methods into the drag performers; these methods are no longer available for customization.

A Lazarus DragObject mainly supplies the cursor and images, used in visual user feedback. Drag-drop operations typically signal acceptance of an possible drop by variations of the mouse cursor, and optionally can attach to it shapes of the dragged object(s). Drag-dock operations instead show a docking rectangle, that snaps to possible target locations when the mouse moves over docksites.

See also

Properties

AlwaysShowDragImagespublicShould the image of dragged objects always be shown?
AutoCreatedpublicWas the drag object created automatically?
AutoFreepublicIndicates whether the object shall be destroyed at the end of the dragging operation.
ControlpublicThe control that is dragged (source).
DragPospublicCurrent mouse position in screen coordinates.
DragTargetpublicThe control over which the object currently is dragged (target).
DragTargetPospublicMouse position in client coordinates of the DragTarget.
DroppedpublicIndicates whether the drag object has been dropped yet.

Methods

EndDragprotectedCalled when a dragging operation ends.
GetDragImagesprotectedReturns a list of images for dragging.
GetDragCursorprotectedReturns the dragging cursor type (shape).
CreatepublicConstructor for the class instance.
AutoCreatepublicSpecial constructor which enforces destruction of the object at the end of the dragging operation.
HideDragImagepublicAsks the image list to hide the drag image.
ShowDragImagepublicAsks the image list to show the drag image.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.