# Class ToolManager

GoJS® Diagramming Components
version 3.0.14
by Northwoods Software®

#### Hierarchy

- Tool
  - ToolManager

This special Tool is responsible for managing all of the Diagram's mode-less tools, which you can access as the Diagram.toolManager.

Mode-less tools are tools that are present in one of the following lists: mouseDownTools, mouseMoveTools, or mouseUpTools. This ToolManager tool is normally the Diagram.defaultTool, so it is also usually the Diagram.currentTool when the user is doing "nothing".

When this tool is running as the current tool, it handles mouse-down, mouse-move, and mouse-up events and the corresponding touch events. For each event it iterates over each of the tools in the corresponding list, calling the tool's Tool.canStart predicate. If that predicate returns true, it starts that tool by making it the diagram's current tool. It then activates the tool and passes on the event to the tool by calling the corresponding method (either Tool.doMouseDown, Tool.doMouseMove, or Tool.doMouseUp).

Because this tool is typically the one running as the diagram's current tool when the user isn't "doing" anything, this tool can also handle other events, such as mouse wheel events and keyboard commands.

Keyboard events are just passed on to the Diagram.commandHandler's CommandHandler.doKeyDown or CommandHandler.doKeyUp method.

This tool also is responsible for showing tooltips. Tooltip Adornments may be declared as any GraphObject.toolTip, or as the Diagram.toolTip if the mouse or finger remains motionless in the background of the diagram. You can set toolTipDuration to control how long the tooltip remains visible after being motionless.

This tool does not utilize any tool handles. This tool does not conduct any transactions. But of course some of the tools that the ToolManager starts can show tool handles and/or conduct their own transactions.

#####
Index

### Constructors

constructor

### Accessors

actionTool
clickCreatingTool
clickSelectingTool
contextMenuTool
currentToolTip
dragSelectingTool
dragSize
draggingTool
gestureBehavior
holdDelay
hoverDelay
linkReshapingTool
linkingTool
mouseDownTools
mouseMoveTools
mouseUpTools
mouseWheelBehavior
panningTool
relinkingTool
resizingTool
rotatingTool
textEditingTool
toolTipDuration

### Methods

doKeyDown
doKeyUp
doMouseDown
doMouseHover
doMouseMove
doMouseUp
doMouseWheel
doToolTip
doWaitAfter
findTool
hideToolTip
initializeStandardTools
positionToolTip
replaceTool
showToolTip

### Properties

GestureCancel
GestureNone
GestureZoom
WheelNone
WheelScroll
WheelZoom

#####
Inherited Index

### Accessors

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

### Methods

Tool.canStart
Tool.canStartMultiTouch
Tool.cancelWaitAfter
Tool.doActivate
Tool.doCancel
Tool.doDeactivate
Tool.doStart
Tool.doStop
Tool.findToolHandleAt
Tool.isBeyondDragSize
Tool.standardMouseClick
Tool.standardMouseOver
Tool.standardMouseSelect
Tool.standardMouseWheel
Tool.standardPinchZoomMove
Tool.standardPinchZoomStart
Tool.standardWaitAfter
Tool.startTransaction
Tool.stopTool
Tool.stopTransaction

## Constructors

### constructor

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

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

  The Tool.name of this tool is "ToolManager".

  The constructor produces a ToolManager that manages no tools. Call initializeStandardTools to create various tools, initialize the tool properties such as draggingTool, and initialize the three mouse tool lists with those newly created tools.

  #### Parameters

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

  #### Returns ToolManager

## Accessors

### actionTool
: ActionTool

- Gets or sets the mode-less ActionTool, normally one of the mouseDownTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### clickCreatingTool
: ClickCreatingTool

- Gets or sets the mode-less ClickCreatingTool, normally one of the mouseUpTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### clickSelectingTool
: ClickSelectingTool

- Gets or sets the mode-less ClickSelectingTool, normally one of the mouseUpTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### contextMenuTool
: ContextMenuTool

- Gets or sets the mode-less ContextMenuTool, normally one of the mouseUpTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### currentToolTip
: Adornment | HTMLInfo

- This read-only property returns the currently showing tooltip, or null if there is none.

### dragSelectingTool
: DragSelectingTool

- Gets or sets the mode-less DragSelectingTool, normally one of the mouseMoveTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### dragSize
: Size

- Gets or sets the distance in view coordinates within which a mouse down-and-up is considered a click and beyond which a mouse movement is considered a drag. The default value is 2 pixels horizontally and vertically for mouse events, and increases by 6 pixels for touch events. This value is used by Tool.isBeyondDragSize.

### draggingTool
: DraggingTool

- Gets or sets the mode-less DraggingTool, normally one of the mouseMoveTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### gestureBehavior
: GestureMode

- Gets or sets the ToolManager's touch pinching behavior. Allowed values are GestureMode values. The default value is GestureMode.Zoom.

  If you want to control whether a single finger touch movement causes a pan (i.e. scroll) of the diagram's contents or scrolls the page, consider either disabling the PanningTool by setting its property Tool.isEnabled to false or by setting PanningTool.bubbles to true.

### holdDelay
: number

- Gets or sets the time between when the mouse stops moving and a hold event, in milliseconds. The default value is 850 milliseconds.

### hoverDelay
: number

- Gets or sets the time between when the mouse stops moving and a hover event, in milliseconds. This value affects the delay before GraphObject.toolTips are shown. The default value is 850 milliseconds.

  Set toolTipDuration to control how long a tooltip will remain visible.

### linkReshapingTool
: LinkReshapingTool

- Gets or sets the mode-less LinkReshapingTool, normally one of the mouseDownTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### linkingTool
: LinkingTool

- Gets or sets the mode-less LinkingTool, normally one of the mouseMoveTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### `Readonly` mouseDownTools
: List<Tool>

- This read-only property returns the list of Tools that might be started upon a mouse or finger press event. When the ToolManager handles a mouse-down or touch-down event in doMouseDown, it searches this list in order, starting the first tool for which Tool.canStart returns true.

  This list may be modified, but it must not be modified while any tool is handling events.

  initializeStandardTools installs the following tools, in order:

  - actionTool, an ActionTool
  - relinkingTool, a RelinkingTool
  - linkReshapingTool, a LinkReshapingTool
  - rotatingTool, a RotatingTool
  - resizingTool, a ResizingTool

### `Readonly` mouseMoveTools
: List<Tool>

- This read-only property returns the list of Tools that might be started upon a mouse or finger move event. When the ToolManager handles a mouse-move or touch-move event in doMouseMove, it searches this list in order, starting the first tool for which Tool.canStart returns true.

  This list may be modified, but it must not be modified while any tool is handling events.

  initializeStandardTools installs the following tools, in order:

  - linkingTool, a LinkingTool
  - draggingTool, a DraggingTool
  - dragSelectingTool, a DragSelectingTool
  - panningTool, a PanningTool

### `Readonly` mouseUpTools
: List<Tool>

- This read-only property returns the list of Tools that might be started upon a mouse or finger up event. When the ToolManager handles a mouse-up or touch-up event in doMouseUp, it searches this list in order, starting the first tool for which Tool.canStart returns true.

  This list may be modified, but it must not be modified while any tool is handling events.

  initializeStandardTools installs the following tools, in order:

  - contextMenuTool, a ContextMenuTool
  - textEditingTool, a TextEditingTool
  - clickCreatingTool, a ClickCreatingTool
  - clickSelectingTool, a ClickSelectingTool

### mouseWheelBehavior
: WheelMode

- Gets or sets the ToolManager's mouse wheel behavior. Allowed values are WheelMode values.

  The default value is WheelMode.Scroll.

### panningTool
: PanningTool

- Gets or sets the mode-less PanningTool, normally one of the mouseMoveTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### relinkingTool
: RelinkingTool

- Gets or sets the mode-less RelinkingTool, normally one of the mouseDownTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### resizingTool
: ResizingTool

- Gets or sets the mode-less ResizingTool, normally one of the mouseDownTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### rotatingTool
: RotatingTool

- Gets or sets the mode-less RotatingTool, normally one of the mouseDownTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### textEditingTool
: TextEditingTool

- Gets or sets the mode-less TextEditingTool, normally one of the mouseUpTools.

  You can disable this tool by setting its Tool.isEnabled property to false.

### toolTipDuration
: number

- Gets or sets how long a tool tip is visible. The default value is 5000 milliseconds.

  This is used by showToolTip to determine how long to wait before calling hideToolTip.

  Set hoverDelay to control how long the mouse should stay stationary before it shows a tooltip.

## Methods

### `Virtual` `Override` doKeyDown

- doKeyDown(): void

- This just calls CommandHandler.doKeyDown on the diagram's Diagram.commandHandler.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` `Override` doKeyUp

- doKeyUp(): void

- This just calls CommandHandler.doKeyUp on the diagram's Diagram.commandHandler.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` `Override` doMouseDown

- doMouseDown(): void

- Iterate over the mouseDownTools list and start the first tool for which its Tool.canStart predicate returns true.

  Starting a tool replaces the Diagram.currentTool with the new tool. Successfully doing so also activates the new tool by calling Tool.doActivate and passes on the mouse-down event to it by calling Tool.doMouseDown.

  Not finding any startable tools causes this tool manager to activate, thereby enabling the mouse-move and mouse-up behaviors and starts detection of a mouse-hold event after holdDelay milliseconds.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` doMouseHover

- doMouseHover(): void

- Implement the standard behavior for mouse hover and mouse hold events, called by doWaitAfter when the mouse has not moved for a period of time.

  If there has been no mouse down, the timer is set for hoverDelay milliseconds. If it executes, it calls any GraphObject.mouseHover function on the object at the mouse or on any of its containing panels, or it calls any Diagram.mouseHover function for a background mouse-hover event.

  If there had been a mouse down, the timer is set for holdDelay milliseconds. If it executes, it calls any GraphObject.mouseHold function on the object at the mouse or on any of its containing panels, or it calls any Diagram.mouseHold function for a background mouse-held-down event.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` `Override` doMouseMove

- doMouseMove(): void

- Iterate over the mouseMoveTools list and start the first tool for which its Tool.canStart predicate returns true.

  Starting a tool replaces the Diagram.currentTool with the new tool. Successfully doing so also activates the new tool by calling Tool.doActivate and passes on the mouse-move event to it by calling Tool.doMouseMove.

  If no tool is found and activated, this:

  - Calls Tool.standardMouseOver to invoke any mouse-enter, mouse-over, or mouse-leave functions.
  - if the mouse has moved sufficiently, such that Tool.isBeyondDragSize is true, this also calls Tool.standardWaitAfter for a possible call to doWaitAfter after hoverDelay milliseconds.
  - Sets the Diagram.lastInput to bubble.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` `Override` doMouseUp

- doMouseUp(): void

- Iterate over the mouseUpTools list and start the first tool for which its Tool.canStart predicate returns true.

  Starting a tool replaces the Diagram.currentTool with the new tool. Successfully doing so also activates the new tool by calling Tool.doActivate and passes on the mouse-up event to it by calling Tool.doMouseUp.

  If no startable tool is found it deactivates this tool manager, to get ready for a mouse-down and ignore mouse-move and mouse-up events.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` `Override` doMouseWheel

- doMouseWheel(): void

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

  By default this just calls Tool.standardMouseWheel. This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` doToolTip

- doToolTip(): void

- Implement the standard behavior for tooltips, called by doWaitAfter when the mouse has not moved for a period of time.

  This looks for a GraphObject at the latest mouse point. If it finds an object, it checks for a GraphObject.toolTip. If it has none, this method searches up the visual tree for a containing Panel that does have a tooltip.

  If it didn't find any object, this looks for a Diagram.toolTip.

  If it eventually finds a tooltip, this calls showToolTip. Otherwise this calls hideToolTip.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` `Override` doWaitAfter

- doWaitAfter(event: InputEvent): void

- Implement the standard behavior for when the mouse has not moved for a period of time. This is due to an expired timer started by calling Tool.standardWaitAfter.

  This calls doMouseHover and, if not mouse-down, doToolTip. Afterwards, if the event that called Tool.standardWaitAfter was a touch event, this simulates a right click, enabling context menu functionality and other actions on touch devices.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Parameters

  - ##### event: InputEvent

    The event that caused standardWaitAfter. In this override, if it is a touch event and the Diagram.lastInput event is not handled (InputEvent.handled set to false), then this method will simulate a right click.

  #### Returns void

### `Virtual` findTool

- findTool(name: string): Tool

- Find a mouse tool of a given name. This searches the mouseDownTools, mouseMoveTools, and mouseUpTools lists.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Parameters

  - ##### name: string

    the type of tool, such as "Dragging" or "ClickSelecting".

  #### Returns Tool

  a Tool whose Tool.name exactly matches the given name, or null if no such tool is found in any of the three lists.

### `Virtual` hideToolTip

- hideToolTip(): void

- Hide any tooltip.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` initializeStandardTools

- initializeStandardTools(): void

- Initialize the three mouse tool lists with instances of the standard tools. This adds new instances of tools to the following three mouse tool lists: mouseDownTools, mouseMoveTools, or mouseUpTools. This also sets the various tool properties of this ToolManager to those newly created tools. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Returns void

### `Virtual` positionToolTip

- positionToolTip(tooltip: Adornment, obj: GraphObject): void

- This is called by showToolTip to position the part within the viewport. It normally goes just below the cursor. But if the mouse is too close to the right edge or the bottom edge of the viewport, it is positioned left and/or above the cursor.

  This method only operates if the tooltip, an Adornment, does not have a Adornment.placeholder. When there is a Placeholder in the tooltip, that Adornment is automatically positioned so that the Placeholder is positioned at the adorned object, the second argument to this method.

  This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  If you override this method to position the tooltip, the tooltip has already been measured but not arranged, so you can use its GraphObject.measuredBounds width and height but not its GraphObject.actualBounds.

  #### Parameters

  - ##### tooltip: Adornment

  - ##### obj: GraphObject

    The GraphObject getting the tooltip, or null if the tooltip is for the diagram background.

  #### Returns void

### `Virtual` replaceTool

- replaceTool(name: string, newtool: Tool): Tool

- Replace a mouse tool of a given name with a new tool, or remove an existing tool (if the newtool is null). This searches the mouseDownTools, mouseMoveTools, and mouseUpTools lists. The new tool is inserted into the same list in which the same-named tool is found, at the same position as the old tool. However, if no existing tool with the given name is present, this does not add the new tool to any list, since it cannot know where it should be added. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Parameters

  - ##### name: string

    the type of tool, such as "Dragging" or "ClickSelecting".

  - ##### newtool: Tool

    If null, any tool that the search finds will just be removed from the list in which it was found.

  #### Returns Tool

  the old tool that was replaced by the new one; this is null if none was found and the new tool was not added to any mouse tool list

### `Virtual` showToolTip

- showToolTip(tooltip: Adornment | HTMLInfo, obj: GraphObject): void

- Show a tooltip Adornment or HTMLInfo. This is called by doToolTip once that method has found a tooltip to display.

  This calls positionToolTip to make it easier to customize how the tooltip is positioned relative to the object with the tooltip.

  This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

  #### Parameters

  - ##### tooltip: Adornment | HTMLInfo

  - ##### obj: GraphObject

    The GraphObject getting the tooltip; this is null if the tooltip is being shown for the diagram background.

  #### Returns void

## Properties

### `Static` `Readonly` GestureCancel

`deprecated`

See GestureMode.Cancel.

### `Static` `Readonly` GestureNone

`deprecated`

See GestureMode.None.

### `Static` `Readonly` GestureZoom

`deprecated`

See GestureMode.Zoom.

### `Static` `Readonly` WheelNone

`deprecated`

See WheelMode.None.

### `Static` `Readonly` WheelScroll

`deprecated`

See WheelMode.Scroll.

### `Static` `Readonly` WheelZoom

`deprecated`

See WheelMode.Zoom.

Copyright © 1998-2024 by Northwoods Software Corporation.