ToolManager class
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.
- Implemented types
- Available extensions
- Annotations
-
- @JS()
- @staticInterop
Constructors
- ToolManager()
-
factory
Properties
- actionTool ↔ ActionTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less ActionTool, normally one of the #mouseDownTools.getter/setter pair - clickCreatingTool ↔ ClickCreatingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less ClickCreatingTool, normally one of the #mouseUpTools.getter/setter pair - clickSelectingTool ↔ ClickSelectingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less ClickSelectingTool, normally one of the #mouseUpTools.getter/setter pair - contextMenuTool ↔ ContextMenuTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less ContextMenuTool, normally one of the #mouseUpTools.getter/setter pair - currentToolTip ↔ dynamic
-
Available on ToolManager, provided by the ToolManager$Typings extension
This read-only property returns the currently showing tooltip, or null if there is none.getter/setter pair - diagram ↔ Diagram
-
Available on Tool, provided by the Tool$Typings extension
This read-only property returns the Diagram that owns this tool and for which this tool is handling input events.getter/setter pair - draggingTool ↔ DraggingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less DraggingTool, normally one of the #mouseMoveTools.getter/setter pair - dragSelectingTool ↔ DragSelectingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less DragSelectingTool, normally one of the #mouseMoveTools.getter/setter pair - dragSize ↔ Size
-
Available on ToolManager, provided by the ToolManager$Typings extension
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.getter/setter pair - gestureBehavior ↔ EnumValue
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the ToolManager's touch pinching behavior. Allowed values are ToolManager.GestureZoom and ToolManager.GestureCancel and ToolManager.GestureNone. The default value is ToolManager.GestureZoom.getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- holdDelay ↔ num
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the time between when the mouse stops moving and a hold event, in milliseconds. The default value is 850 milliseconds.getter/setter pair - hoverDelay ↔ num
-
Available on ToolManager, provided by the ToolManager$Typings extension
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.getter/setter pair - isActive ↔ bool
-
Available on Tool, provided by the Tool$Typings extension
Gets or sets whether this tool is started and is actively doing something.getter/setter pair - isEnabled ↔ bool
-
Available on Tool, provided by the Tool$Typings extension
Gets or sets whether this tool can be started by a mouse event.getter/setter pair - linkingTool ↔ LinkingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less LinkingTool, normally one of the #mouseMoveTools.getter/setter pair - linkReshapingTool ↔ LinkReshapingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less LinkReshapingTool, normally one of the #mouseDownTools.getter/setter pair -
mouseDownTools
↔ List<
Tool> -
Available on ToolManager, provided by the ToolManager$Typings extension
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.getter/setter pair -
mouseMoveTools
↔ List<
Tool> -
Available on ToolManager, provided by the ToolManager$Typings extension
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.getter/setter pair -
mouseUpTools
↔ List<
Tool> -
Available on ToolManager, provided by the ToolManager$Typings extension
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.getter/setter pair - mouseWheelBehavior ↔ EnumValue
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the ToolManager's mouse wheel behavior. Allowed values are ToolManager.WheelScroll and ToolManager.WheelZoom and ToolManager.WheelNone.getter/setter pair - name ↔ String
-
Available on Tool, provided by the Tool$Typings extension
Gets or sets the name of this tool. The default name is an empty string, but the constructor for each instance of a subclass of Tool will initialize it appropriately. For example, the name of the DragSelectingTool is "DragSelecting".getter/setter pair - panningTool ↔ PanningTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less PanningTool, normally one of the #mouseMoveTools.getter/setter pair - relinkingTool ↔ RelinkingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less RelinkingTool, normally one of the #mouseDownTools.getter/setter pair - resizingTool ↔ ResizingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less ResizingTool, normally one of the #mouseDownTools.getter/setter pair - rotatingTool ↔ RotatingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less RotatingTool, normally one of the #mouseDownTools.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- textEditingTool ↔ TextEditingTool
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets the mode-less TextEditingTool, normally one of the #mouseUpTools.getter/setter pair - toolTipDuration ↔ num
-
Available on ToolManager, provided by the ToolManager$Typings extension
Gets or sets how long a tool tip is visible. The default value is 5000 milliseconds.getter/setter pair - transactionResult ↔ String?
-
Available on Tool, provided by the Tool$Typings extension
Gets or sets the name of the transaction to be committed by #stopTransactiongetter/setter pair
Methods
-
cancelWaitAfter(
) → void -
Available on Tool, provided by the Tool$Typings extension
This is called to cancel any running "WaitAfter" timer. -
canStart(
) → bool -
Available on Tool, provided by the Tool$Typings extension
This predicate is used by the ToolManager to decide if this tool can be started mode-lessly by mouse and touch events. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state. -
canStartMultiTouch(
) → bool -
Available on Tool, provided by the Tool$Typings extension
Called by ToolManager#doMouseDown and ToolManager#doMouseMove, this method determines whether or not to allow pinch zooming from a multi-touch event. By default this predicate just returns true. This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method. @expose @return {boolean} @see #standardPinchZoomStart @see #standardPinchZoomMove @since 1.5 -
doActivate(
) → void -
Available on Tool, provided by the Tool$Typings extension
The Diagram calls this method after setting Diagram#currentTool, to make the new tool active. This should set #isActive to true. Overrides of this method might call #startTransaction, if this tool's activity involves modification of the model. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state. -
doCancel(
) → void -
Available on Tool, provided by the Tool$Typings extension
The diagram will call this method when the user wishes to cancel the current tool's operation. Typically this is called when the user hits the ESCAPE key. This should restore the original state of what was modified by this tool, and then it should call #stopTool. This method is not responsible for cleaning up any side-effects that should be performed by #doDeactivate and/or #doStop, which will always be called whether the tool stops normally or abnormally. -
doDeactivate(
) → void -
Available on Tool, provided by the Tool$Typings extension
The Diagram calls this method on the old tool when Diagram#currentTool is set to a new tool. This needs to set #isActive to false. Overrides of this method might call #stopTransaction, if this tool's activity involves modification of the model. -
doKeyDown(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
This just calls CommandHandler#doKeyDown on the diagram's Diagram#commandHandler. -
doKeyDown(
) → void -
Available on Tool, provided by the Tool$Typings extension
The diagram will call this method upon a key down event. By default this just calls #doCancel if the key is the ESCAPE key. Implementations of this method can look at Diagram#lastInput to get the key. -
doKeyUp(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
This just calls CommandHandler#doKeyUp on the diagram's Diagram#commandHandler. -
doKeyUp(
) → void -
Available on Tool, provided by the Tool$Typings extension
The diagram will call this method upon a key up event. Implementations of this method can look at Diagram#lastInput to get the key. -
doMouseDown(
) → void -
Available on Tool, provided by the Tool$Typings extension
The diagram will call this method upon a mouse down event. This is normally overridden for mouse-down tools; it is not called for mouse-move or mouse-up tools. However it may also be called when the tool is run in a modal fashion, when code explicitly sets the diagram's Diagram#currentTool. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state. -
doMouseDown(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
Iterate over the #mouseDownTools list and start the first tool for which its Tool#canStart predicate returns true. -
doMouseHover(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
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. -
doMouseMove(
) → void -
Available on Tool, provided by the Tool$Typings extension
The diagram will call this method upon a mouse move event. This is normally overridden for mouse-move tools; it is not called for mouse-up tools. However it may also be called when the tool is run in a modal fashion, when code explicitly sets the diagram's Diagram#currentTool. An override of this method usually does nothing when #isActive is false. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state. -
doMouseMove(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
Iterate over the #mouseMoveTools list and start the first tool for which its Tool#canStart predicate returns true. -
doMouseUp(
) → void -
Available on Tool, provided by the Tool$Typings extension
The diagram will call this method upon a mouse up event. This is normally overridden for mouse-up tools. An override of this method usually does nothing when #isActive is false, except for calling #stopTool. Tools normally stop upon a mouse up, by calling #stopTool. If you want to handle multiple mouse down-up gestures in one tool activation, you will need to override this method to only stop the tool when you want. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state. -
doMouseUp(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
Iterate over the #mouseUpTools list and start the first tool for which its Tool#canStart predicate returns true. -
doMouseWheel(
) → void -
Available on Tool, provided by the Tool$Typings extension
The diagram will call this method as the mouse wheel is rotated. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state. -
doMouseWheel(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
The diagram will call this method as the mouse wheel is rotated. -
doStart(
) → void -
Available on Tool, provided by the Tool$Typings extension
The Diagram calls this method when this tool becomes the current tool; you should not call this method. Tool implementations should perform their per-use initialization here, such as setting up internal data structures, or capturing the mouse. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state. -
doStop(
) → void -
Available on Tool, provided by the Tool$Typings extension
The Diagram calls this method when this tool stops being the current tool; you should not call this method. Tool implementations should perform their per-use cleanup here, such as releasing mouse capture. -
doToolTip(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
Implement the standard behavior for tooltips, called by #doWaitAfter when the mouse has not moved for a period of time. -
doWaitAfter(
InputEvent event) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
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. -
doWaitAfter(
InputEvent event) → void -
Available on Tool, provided by the Tool$Typings extension
This is called a certain delay after a call to #standardWaitAfter if there has not been any call to #cancelWaitAfter. The ToolManager overrides this method in order to implement support for mouse-hover behavior and tooltips. -
findTool(
String name) → Tool? -
Available on ToolManager, provided by the ToolManager$Typings extension
Find a mouse tool of a given name. This searches the #mouseDownTools, #mouseMoveTools, and #mouseUpTools lists. -
findToolHandleAt(
Point p, String category) → GraphObject? -
Available on Tool, provided by the Tool$Typings extension
This convenience function finds the front-most GraphObject that is at a given point and that is an element of an Adornment that is of a given category. The tool handle must be an immediate element of the Adornment, not a GraphObject that is nested within Panels within the Adornment. -
hideToolTip(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
Hide any tooltip. -
initializeStandardTools(
) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
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. @expose -
isBeyondDragSize(
[Point? first, Point? last]) → bool -
Available on Tool, provided by the Tool$Typings extension
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. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
positionToolTip(
Adornment tooltip, GraphObject obj) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
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. -
replaceStandardTool(
String name, Tool newtool, List< Tool> list) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
(undocumented) @param {string} name @param {Tool} newtool @param {List. -
replaceTool(
String name, Tool newtool) → Tool? -
Available on ToolManager, provided by the ToolManager$Typings extension
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. @expose @param {string} name the type of tool, such as "Dragging" or "ClickSelecting". @param {Tool} newtool If null, any tool that the search finds will just be removed from the list in which it was found. @return {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 -
showToolTip(
Object tooltip, GraphObject obj) → void -
Available on ToolManager, provided by the ToolManager$Typings extension
Show a tooltip Adornment or HTMLInfo. This is called by #doToolTip once that method has found a tooltip to display. -
standardMouseClick<
T extends GraphObject> ([bool pred(T)?]) → bool -
Available on Tool, provided by the Tool$Typings extension
Implement the standard behavior for mouse clicks, searching for and calling click handler functions on GraphObjects or on Diagram, and raising the corresponding DiagramEvent. -
standardMouseOver(
) → void -
Available on Tool, provided by the Tool$Typings extension
Implement the standard behavior for mouse enter, over, and leave events, where the mouse is moving but no button is pressed. This should be called by mouse move event handlers when wanting to detect and invoke mouse enter/over/leave event handlers. -
standardMouseSelect(
) → void -
Available on Tool, provided by the Tool$Typings extension
Implement the standard behavior for selecting parts with the mouse, depending on the control and shift modifier keys. -
standardMouseWheel(
) → void -
Available on Tool, provided by the Tool$Typings extension
Implement the standard behavior for mouse wheel events. ToolManager#doMouseWheel calls this method. -
standardPinchZoomMove(
) → void -
Available on Tool, provided by the Tool$Typings extension
Continues pinch-zooming (started by #standardPinchZoomStart on multi-touch devices. -
standardPinchZoomStart(
) → void -
Available on Tool, provided by the Tool$Typings extension
Initiates pinch-zooming on multi-touch devices. -
standardWaitAfter(
num delay, [InputEvent? event]) → void -
Available on Tool, provided by the Tool$Typings extension
This is called to start a new timer to call #doWaitAfter after a given delay. It first cancels any previously running "WaitAfter" timer, by calling #cancelWaitAfter. -
startTransaction(
[String? tname]) → bool -
Available on Tool, provided by the Tool$Typings extension
Call Diagram#startTransaction with the given transaction name. This always sets #transactionResult to null. -
stopTool(
) → void -
Available on Tool, provided by the Tool$Typings extension
If the Diagram#currentTool is this tool, stop this tool and start the Diagram#defaultTool by making it be the new current tool. The implementation of various tool methods can call this method to stop the current tool. This will call #doStop -- you should not call that method directly. -
stopTransaction(
) → bool -
Available on Tool, provided by the Tool$Typings extension
If #transactionResult is null, call Diagram#rollbackTransaction, otherwise call Diagram#commitTransaction. -
toString(
) → String -
A string representation of this object.
inherited
-
updateAdornments(
Part part) → void -
Available on Tool, provided by the Tool$Typings extension
The diagram asks each tool to update any adornments the tool might use for a given part. If the tool uses its own tool handles, this should display them or hide them as appropriate. Typically this should only show them if the part is selected.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- 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.
getter/setter pair
- 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).
getter/setter pair
- gestureZoom ↔ EnumValue
-
This value for #gestureBehavior indicates that the pointer/touch pinch gestures
on the canvas intend to zoom the Diagram.
getter/setter pair
- 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.
getter/setter pair
- wheelScroll ↔ EnumValue
-
This default value for #mouseWheelBehavior indicates that mouse wheel events scroll the diagram.
getter/setter pair
- wheelZoom ↔ EnumValue
-
This value for #mouseWheelBehavior indicates that the mouse wheel events change the scale of the diagram.
getter/setter pair