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. Extensions can be found in the GoJS kit under the `extensions` or `extensionsTS` folders. See the Extensions intro page for more information.

### Hierarchy

- Tool
  - NodeLabelDraggingTool

The NodeLabelDraggingTool class lets the user move a label on a Node.

This tool only works when the Node has a label (any GraphObject) marked with { _isNodeLabel: true } that is positioned in a Spot Panel. It works by modifying that label's GraphObject.alignment property to have an offset from the center of the panel.

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

## Index

### Constructors

- constructor

### Properties

- label

### Methods

- canStart
- doActivate
- doCancel
- doDeactivate
- doMouseMove
- doMouseUp
- doStop
- findLabel
- updateAlignment

## Constructors

### constructor

- new NodeLabelDraggingTool(): NodeLabelDraggingTool

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

  #### Returns NodeLabelDraggingTool

## Properties

### label : GraphObject | null

The label being dragged.

## 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 Spot 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 GraphObject.alignment property.

  #### Returns void

### Override doCancel

- doCancel(): void

- Restore the label's original value for GraphObject.alignment.

  #### Returns void

### Override doDeactivate

- doDeactivate(): void

- Stop any ongoing transaction.

  #### Returns void

### Override doMouseMove

- doMouseMove(): void

- During the drag, call updateAlignment in order to set the GraphObject.alignment of the label.

  #### Returns void

### Override doMouseUp

- doMouseUp(): void

- At the end of the drag, update the alignment 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 | null

- From the GraphObject at the mouse point, search up the visual tree until we get to an object that has the "_isNodeLabel" property set to true, that is in a Spot Panel, and that is not the first element of that Panel (i.e. not the main element of the panel).

  #### Returns GraphObject | null

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

### updateAlignment

- updateAlignment(): void

- Save the label's GraphObject.alignment as an absolute offset from the center of the Spot Panel that the label is in.

  #### Returns void

Copyright © 1998-2019 by Northwoods Software Corporation.