# Class LinkLabelDraggingTool

GoJS® Diagramming Components
version 3.0.14
by Northwoods Software®

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

#### Hierarchy

- Tool
  - LinkLabelDraggingTool

The LinkLabelDraggingTool class lets the user move a label on a go.Link.

This tool only works when the Link has a label that is positioned at the go.Link.midPoint plus some offset. It does not work for labels that have a particular go.GraphObject.segmentIndex.

If you want to experiment with this extension, try the Link Label Dragging sample.

#####
Index

### Constructors

constructor

### Methods

canStart
doActivate
doCancel
doDeactivate
doMouseMove
doMouseUp
doStop
findLabel
updateSegmentOffset

### Properties

label

#####
Inherited Index

### Accessors

Tool.diagram
Tool.isActive
Tool.isEnabled
Tool.name
Tool.transactionResult

### Methods

Tool.canStartMultiTouch
Tool.cancelWaitAfter
Tool.doKeyDown
Tool.doKeyUp
Tool.doMouseDown
Tool.doMouseWheel
Tool.doStart
Tool.doWaitAfter
Tool.findToolHandleAt
Tool.isBeyondDragSize
Tool.standardMouseClick
Tool.standardMouseOver
Tool.standardMouseSelect
Tool.standardMouseWheel
Tool.standardPinchZoomMove
Tool.standardPinchZoomStart
Tool.standardWaitAfter
Tool.startTransaction
Tool.stopTool
Tool.stopTransaction
Tool.updateAdornments

## Constructors

### constructor

- new LinkLabelDraggingTool(init?: Partial<LinkLabelDraggingTool>): LinkLabelDraggingTool

- Constructs a LinkLabelDraggingTool and sets the name for the tool.

  #### Parameters

  - ##### `Optional` init: Partial<LinkLabelDraggingTool>

  #### Returns LinkLabelDraggingTool

## Methods

### `Override` canStart

- canStart(): boolean

- This tool can only start if the mouse has moved enough so that it is not a click, and if the mouse down point is on a GraphObject "label" in a Link Panel, as determined by findLabel.

  #### Returns boolean

### `Override` doActivate

- doActivate(): void

- Start a transaction, call findLabel and remember it as the "label" property, and remember the original value for the label's go.GraphObject.segmentOffset property.

  #### Returns void

### `Override` doCancel

- doCancel(): void

- Restore the label's original value for go.GraphObject.segmentOffset.

  #### Returns void

### `Override` doDeactivate

- doDeactivate(): void

- Stop any ongoing transaction.

  #### Returns void

### `Override` doMouseMove

- doMouseMove(): void

- During the drag, call updateSegmentOffset in order to set the go.GraphObject.segmentOffset of the label.

  #### Returns void

### `Override` doMouseUp

- doMouseUp(): void

- At the end of the drag, update the segment offset of the label and finish the tool, completing a transaction.

  #### Returns void

### `Override` doStop

- doStop(): void

- Clear any reference to a label element.

  #### Returns void

### findLabel

- findLabel(): GraphObject

- From the GraphObject at the mouse point, search up the visual tree until we get to an object that is a label of a Link.

  #### Returns GraphObject

  This returns null if no such label is at the mouse down point.

### updateSegmentOffset

- updateSegmentOffset(): void

- Save the label's go.GraphObject.segmentOffset as a rotated offset from the midpoint of the Link that the label is in.

  #### Returns void

## Properties

### label
: GraphObject

The label being dragged.

Copyright © 1998-2024 by Northwoods Software Corporation.