Class ToolManager

This special Tool is responsible for managing all of the Diagram's mode-less tools.

Hierarchy

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(): 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.

Returns

ToolManager

Properties

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

public static WheelScroll: EnumValue

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

public static WheelZoom: EnumValue

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

public actionTool: ActionTool

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

public clickCreatingTool: ClickCreatingTool

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

public clickSelectingTool: ClickSelectingTool

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

public contextMenuTool: ContextMenuTool

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

public currentToolTip: Adornment

Gets the currently showing tooltip, or null if there is none.

public diagram: Diagram

Gets the Diagram that owns this tool and for which this tool is handling input events.

public dragSelectingTool: DragSelectingTool

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

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

public draggingTool: DraggingTool

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

public holdDelay: number

Gets or sets the time between when the mouse stops moving and a hold event, in milliseconds.

public hoverDelay: number

Gets or sets the time between when the mouse stops moving and a hover event, in milliseconds.

public isActive: boolean

Gets or sets whether this tool is started and is actively doing something.

public isEnabled: boolean

Gets or sets whether this tool can be started by a mouse event.

public linkReshapingTool: LinkReshapingTool

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

public linkingTool: LinkingTool

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

public mouseDownTools: List

Gets the list of Tools that might be started upon a mouse-down event.

public mouseMoveTools: List

Gets the list of Tools that might be started upon a mouse-move event.

public mouseUpTools: List

Gets the list of Tools that might be started upon a mouse-up event.

public mouseWheelBehavior: EnumValue

Gets or sets the ToolManager's mouse wheel behavior.

public name: string

Gets or sets the name of this tool.

public panningTool: PanningTool

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

public relinkingTool: RelinkingTool

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

public resizingTool: ResizingTool

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

public rotatingTool: RotatingTool

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

public textEditingTool: TextEditingTool

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

public transactionResult: string

Gets or sets the name of the transaction to be committed by #stopTransaction; if null, the transaction will be rolled back.

Methods

public canStart(): boolean

This predicate is used by the ToolManager to decide if this tool can be started mode-lessly by mouse and touch events.

Returns

boolean

public cancelWaitAfter(): any

This is called to cancel any running "WaitAfter" timer.

Returns

any

public doActivate(): any

This method is called by the diagram after setting Diagram#currentTool, to make the new tool active.

Returns

any

public doCancel(): any

The diagram will call this method when the user wishes to cancel the current tool's operation.

Returns

any

public doDeactivate(): any

This method is called by the diagram on the old tool when Diagram#currentTool is set to a new tool.

Returns

any

public doKeyDown(): any

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

Returns

any

public doKeyUp(): any

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

Returns

any

public doMouseDown(): any

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

Returns

any

public doMouseHover(): any

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.

Returns

any

public doMouseMove(): any

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

Returns

any

public doMouseUp(): any

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

Returns

any

public doMouseWheel(): any

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

Returns

any

public doStart(): any

This method is called by the diagram when this tool becomes the current tool; you should not call this method.

Returns

any

public doStop(): any

This method is called by the diagram when this tool stops being the current tool; you should not call this method.

Returns

any

public doToolTip(): any

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

Returns

any

public doWaitAfter(): any

Implement the standard behavior for when the mouse has not moved for a period of time.

Returns

any

public findTool(name: string): Tool

Find a mouse tool of a given name.

Parameters

  • name: string

Returns

Tool

public findToolHandleAt(p: Point, category: string): GraphObject

This convenience function finds the front-most GraphObject that is at a given point and that is part of an Adornment that is of a given category.

Parameters

  • p: Point

    a Point in document coordinates.

  • category: string

    the required Part#category of the Adornment.

Returns

GraphObject

public hideToolTip(): any

Hide any tooltip.

Returns

any

public initializeStandardTools(): any

Initialize the three mouse tool lists with instances of the standard tools.

Returns

any

public isBeyondDragSize(first?: Point, last?: Point): boolean

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.

Parameters

  • first?: Point optional

    Point in view coordinates, defaults to Diagram#firstInput's InputEvent#viewPoint.

  • last?: Point optional

    Point in view coordinates, defaults to Diagram#lastInput's InputEvent#viewPoint.

Returns

boolean

public positionToolTip(tooltip: Adornment, obj: GraphObject): any

This is called by #showToolTip to position the part within the viewport.

Parameters

Returns

any

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

Replace a mouse tool of a given name with a new tool.

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

public showToolTip(tooltip: Adornment, obj: GraphObject): any

Show a tooltip Adornment.

Parameters

  • tooltip: Adornment
  • obj: GraphObject

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

Returns

any

public standardMouseClick(navig?: (obj: go.GraphObject) => go.GraphObject, pred?: (obj: go.GraphObject) => boolean): any

Implement the standard behavior for mouse clicks, searching for and calling click handler functions on GraphObjects or on Diagram, and raising the corresponding DiagramEvent.

Parameters

  • navig?: (obj: go.GraphObject) => go.GraphObject optional

    An optional custom navigation function to find target objects.

  • pred?: (obj: go.GraphObject) => boolean optional

    An optional custom predicate

Returns

any

public standardMouseOver(): any

Implement the standard behavior for mouse enter, over, and leave events, where the mouse is moving but no button is pressed.

Returns

any

public standardMouseSelect(): any

Implement the standard behavior for selecting parts with the mouse, depending on the control and shift modifier keys.

Returns

any

public standardMouseWheel(): any

Implement the standard behavior for mouse wheel events.

Returns

any

public standardWaitAfter(delay: number): any

This is called to start a new timer to call #doWaitAfter after a given delay.

Parameters

  • delay: number

    in milliseconds

Returns

any

public startTransaction(tname?: string): boolean

Call Diagram#startTransaction with the given transaction name.

Parameters

  • tname?: string optional

    a description of the transaction

Returns

boolean

public stopTool(): any

If the Diagram#currentTool is this tool, stop this tool and start the Diagram#defaultTool by making it be the new current tool.

Returns

any

public stopTransaction(): boolean

If #transactionResult is null, call Diagram#rollbackTransaction, otherwise call Diagram#commitTransaction.

Returns

boolean

public updateAdornments(part: Part): any

The diagram asks each tool to update any adornments the tool might use for a given part.

Parameters

Returns

any