startDrag method
Makes this object draggable. When this object is dragged, its x and y
properties will be updated to match the mouse position.
The lockCenter
parameter, if set to true, will cause the object to be
dragged from its center point.
The bounds
parameter can be used to restrict the movement of the object
to a certain area.
Throws an error if the object is not visible or touchable.
Implementation
void startDrag([bool lockCenter = false, GRect? bounds]) {
if (!inStage || !$hasTouchableArea) {
throw 'to drag an object, it has to be visible and enabled in the stage.';
}
$currentDrag?.stopDrag();
$currentDrag = this;
$currentDragBounds = bounds;
_dragCenterOffset = GPoint();
if (lockCenter) {
_dragCenterOffset.setTo(x - parent!.mouseX, y - parent!.mouseY);
}
stage!.onMouseMove.add(_handleDrag);
}