Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ToolManager

Hierarchy

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

  • 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.

    Returns ToolManager

Properties

actionTool : ActionTool

clickCreatingTool : ClickCreatingTool

clickSelectingTool : ClickSelectingTool

contextMenuTool : ContextMenuTool

currentToolTip : Adornment | HTMLInfo

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

dragSelectingTool : DragSelectingTool

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.

    since

    1.2

draggingTool : DraggingTool

gestureBehavior : EnumValue

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

linkingTool : LinkingTool

Read-only mouseDownTools : List<Tool>

Read-only mouseMoveTools : List<Tool>

Read-only mouseUpTools : List<Tool>

mouseWheelBehavior : EnumValue

panningTool : PanningTool

relinkingTool : RelinkingTool

resizingTool : ResizingTool

rotatingTool : RotatingTool

textEditingTool : TextEditingTool

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

Override Virtual 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

Override Virtual 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

Override Virtual 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

Override Virtual doMouseMove

  • doMouseMove(): void

Override Virtual 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

Override Virtual 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

Override Virtual doWaitAfter

  • 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

    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

  • 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

    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

  • 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

Constants

Static GestureCancel : EnumValue

This value for gestureBehavior indicates that the pointer/touch pinch gestures on the canvas intend to have no effect on the Diagram, but also no effect on the page.

since

1.5

Static GestureNone : EnumValue

This value for gestureBehavior indicates that the pointer/touch pinch gestures on the canvas intend to have no effect on the Diagram, but will not be prevented, and may bubble up the page to have other effects (such as zooming the page).

since

1.5

Static GestureZoom : EnumValue

This value for gestureBehavior indicates that the pointer/touch pinch gestures on the canvas intend to zoom the Diagram.

since

1.5

Static WheelNone : EnumValue

This value for mouseWheelBehavior indicates that the mouse wheel events are ignored, although scrolling or zooming by other means may still be allowed.

since

1.2

Static WheelScroll : EnumValue

This default value for mouseWheelBehavior indicates that mouse wheel events scroll the diagram.

Static WheelZoom : EnumValue

This value for mouseWheelBehavior indicates that the mouse wheel events change the scale of the diagram.