Class DraggingTool

The DraggingTool is used to move or copy selected parts with the mouse. Dragging the selection moves parts for which Part#canMove is true. If the user holds down the Control key, this tool will make a copy of the parts being dragged, for those parts for which Part#canCopy is true.

Hierarchy

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(): DraggingTool

You do not normally need to create an instance of this tool because one already exists as the ToolManager#draggingTool, which you can modify.

Returns

DraggingTool

Properties

public copiedParts: Map

Gets the collection of Parts that this tool has copied.

public copiesEffectiveCollection: boolean

Gets or sets whether for a copying operation the extended selection is copied or only the selected parts.

public currentPart: Part

Gets the Part found at the mouse point.

public delay: number

On touch gestures only, this property gets or sets the time in milliseconds for which the mouse must be stationary before this tool can be started.

public diagram: Diagram

Gets the Diagram that owns this tool and for which this tool is handling input events.

public draggedParts: Map

Gets the collection of Parts being dragged.

public dragsTree: boolean

Gets or sets whether moving or copying a node also includes all of the node's tree children and their descendants, along with the links to those additional nodes.

public gridSnapCellSize: Size

Gets or sets the size of the grid cell used when snapping during a drag if the value of #isGridSnapEnabled is true.

public gridSnapCellSpot: Spot

Gets or sets the Spot that specifies what point in the grid cell dragged parts snap to, if the value of #isGridSnapEnabled is true.

public gridSnapOrigin: Point

Gets or sets the snapping grid's origin point, in document coordinates, if the value of #isGridSnapEnabled is true.

public isActive: boolean

Gets or sets whether this tool is started and is actively doing something.

public isEnabled: boolean

Gets or sets whether this tool can be started by a mouse event.

public isGridSnapEnabled: boolean

Gets or sets whether the DraggingTool snaps objects to grid points.

public isGridSnapRealtime: boolean

Gets or sets whether the DraggingTool snaps objects to grid points during the drag.

public name: string

Gets or sets the name of this tool.

public transactionResult: string

Gets or sets the name of the transaction to be committed by #stopTransaction; if null, the transaction will be rolled back.

Methods

public canStart(): boolean

This tool can run if the diagram allows selection and moves/copies/dragging-out, if the mouse has moved far enough away to be a drag and not a click, and if #findDraggablePart has found a selectable part at the mouse-down point.

Returns

boolean

public cancelWaitAfter(): any

This is called to cancel any running "WaitAfter" timer.

Returns

any

public computeEffectiveCollection(parts: Iterable): Map

Find the actual collection of nodes and links to be moved or copied, given an initial collection.

Parameters

  • parts: Iterable

    A Set or List of Parts.

Returns

Map

public computeMove(n: Part, newloc: Point, draggedparts?: Map, result?: Point): Point

This method computes the new location for a Node or simple Part, given a new desired location and an optional Map of dragged parts, taking any grid-snapping into consideration, any Part#dragComputation function, and any Part#minLocation and Part#maxLocation.

Parameters

  • n: Part
  • newloc: Point
  • draggedparts?: Map optional

    an optional Map mapping Parts to JavaScript Objects that have a "point" property remembering the original location of that Part.

  • result?: Point optional

    an optional Point that is modified and returned

Returns

Point

public doActivate(): any

Start the dragging operation.

Returns

any

public doCancel(): any

Abort any dragging operation.

Returns

any

public doDeactivate(): any

Stop the dragging operation by stopping the transaction and cleaning up any temporary state.

Returns

any

public doDragOver(pt: Point, obj: GraphObject): any

Perform any additional side-effects during a drag, whether an internal move or copy or an external drag, that may affect the existing non-moved object(s).

Parameters

  • pt: Point

    a Point in document coordinates.

  • obj: GraphObject

    the GraphObject at the point, excluding what is being dragged or temporary objects; the argument may be null if the drag is occurring in the background of the diagram. Use GraphObject#part to get the Node or Part at the root of the visual tree of the stationary object.

Returns

any

public doDropOnto(pt: Point, obj: GraphObject): any

Perform any additional side-effects after a drop, whether an internal move or copy or an external drop, that may affect the existing non-moved object(s).

Parameters

  • pt: Point

    a Point in document coordinates.

  • obj: GraphObject

    the GraphObject where the drop occurred, excluding what was dropped or temporary objects; the argument may be null if the drop occurred in the background of the diagram. Use GraphObject#part to get the Node or Part at the root of the visual tree of the stationary object.

Returns

any

public doKeyDown(): any

Handle switching between copying and moving modes as the Control key is pressed or released.

Returns

any

public doKeyUp(): any

Handle switching between copying and moving modes as the Control key is pressed or released.

Returns

any

public doMouseDown(): any

The diagram will call this method upon a mouse down event.

Returns

any

public doMouseMove(): any

Move the #draggedParts (or if copying, the #copiedParts) to follow the current mouse point.

Returns

any

public doMouseUp(): any

On a mouse-up finish moving or copying the effective selection.

Returns

any

public doMouseWheel(): any

The diagram will call this method as the mouse wheel is rotated.

Returns

any

public doStart(): any

This method is called by the diagram when this tool becomes the current tool; you should not call this method.

Returns

any

public doStop(): any

This method is called by the diagram when this tool stops being the current tool; you should not call this method.

Returns

any

public doWaitAfter(): any

This is called a certain delay after a call to #standardWaitAfter if there has not been any call to #cancelWaitAfter.

Returns

any

public findDraggablePart(): Part

Return the selectable and movable/copyable Part at the mouse-down point.

Returns

Part

public findToolHandleAt(p: Point, category: string): GraphObject

This convenience function finds the front-most GraphObject that is at a given point and that is part of an Adornment that is of a given category.

Parameters

  • p: Point

    a Point in document coordinates.

  • category: string

    the required Part#category of the Adornment.

Returns

GraphObject

public isBeyondDragSize(first?: Point, last?: Point): boolean

Return true when the last mouse point is far enough away from the first mouse down point to constitute a drag operation instead of just a potential click.

Parameters

  • first?: Point optional

    Point in view coordinates, defaults to Diagram#firstInput's InputEvent#viewPoint.

  • last?: Point optional

    Point in view coordinates, defaults to Diagram#lastInput's InputEvent#viewPoint.

Returns

boolean

public mayCopy(): boolean

This predicate is true when the diagram allows objects to be copied and inserted, and some object in the selection is copyable, and the user is holding down the Control key.

Returns

boolean

public mayMove(): boolean

This predicate is true when the diagram allows objects to be moved, and some object in the selection is movable.

Returns

boolean

public moveParts(parts: Map, offset: Point, check: boolean): any

Move a collection of Parts by a given offset.

Parameters

  • parts: Map

    a Map mapping Parts to JavaScript Objects that have a "point" property remembering the original location of that Part.

  • offset: Point
  • check: boolean

    Whether to check Part#canMove on each part.

Returns

any

public standardMouseClick(navig?: (obj: go.GraphObject) => go.GraphObject, pred?: (obj: go.GraphObject) => boolean): any

Implement the standard behavior for mouse clicks, searching for and calling click handler functions on GraphObjects or on Diagram, and raising the corresponding DiagramEvent.

Parameters

  • navig?: (obj: go.GraphObject) => go.GraphObject optional

    An optional custom navigation function to find target objects.

  • pred?: (obj: go.GraphObject) => boolean optional

    An optional custom predicate

Returns

any

public standardMouseOver(): any

Implement the standard behavior for mouse enter, over, and leave events, where the mouse is moving but no button is pressed.

Returns

any

public standardMouseSelect(): any

This override prevents the Control modifier unselecting an already selected part.

Returns

any

public standardMouseWheel(): any

Implement the standard behavior for mouse wheel events.

Returns

any

public standardWaitAfter(delay: number): any

This is called to start a new timer to call #doWaitAfter after a given delay.

Parameters

  • delay: number

    in milliseconds

Returns

any

public startTransaction(tname?: string): boolean

Call Diagram#startTransaction with the given transaction name.

Parameters

  • tname?: string optional

    a description of the transaction

Returns

boolean

public stopTool(): any

If the Diagram#currentTool is this tool, stop this tool and start the Diagram#defaultTool by making it be the new current tool.

Returns

any

public stopTransaction(): boolean

If #transactionResult is null, call Diagram#rollbackTransaction, otherwise call Diagram#commitTransaction.

Returns

boolean

public updateAdornments(part: Part): any

The diagram asks each tool to update any adornments the tool might use for a given part.

Parameters

Returns

any