Class ContextMenuTool

The ContextMenuTool is used to create and show a context menu. It automatically disables any browser context menu.

Hierarchy

  • Tool
    • ContextMenuTool

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(): ContextMenuTool

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

Returns

ContextMenuTool

Properties

public currentContextMenu: Adornment

Gets the currently showing context menu, 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 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 mouseDownPoint: Point

Gets the original mouse-down point in document coordinates.

public name: string

Gets or sets the name of this tool.

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

Return true if it's a mouse right click that hasn't moved Tool#isBeyondDragSize and that is on a GraphObject with a GraphObject#contextMenu.

Returns

boolean

public cancelWaitAfter(): any

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

Returns

any

public doActivate(): any

Do nothing, activation is special and relies on doMouseUp

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

The diagram will call this method upon a key down event.

Returns

any

public doKeyUp(): any

The diagram will call this method upon a key up event.

Returns

any

public doMouseDown(): any

The diagram will call this method upon a mouse down event.

Returns

any

public doMouseMove(): any

Handle mouse-enter, mouse-over, and mouse-leave events.

Returns

any

public doMouseUp(): any

If there is something found by #findObjectWithContextMenu, call #showContextMenu with that object's GraphObject#contextMenu or Diagram#contextMenu.

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 doWaitAfter(): any

This is called a certain delay after a call to #standardWaitAfter if there has not been any call to #cancelWaitAfter.

Returns

any

public findObjectWithContextMenu(): any

Find a GraphObject at the current mouse point with a GraphObject#contextMenu, or return the Diagram if there is a Diagram#contextMenu.

Returns

any

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 hideContextMenu(): any

Hide any context menu.

Returns

any

public hideDefaultContextMenu(): any

Hide the default context menu.

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 positionContextMenu(contextmenu: Adornment, obj: GraphObject): any

This is called by #showContextMenu to position the context menu within the viewport.

Parameters

Returns

any

public showContextMenu(contextmenu: Adornment, obj: GraphObject): any

Show an Adornment as a context menu.

Parameters

Returns

any

public showDefaultContextMenu(): any

Show a series of HTML elements acting as a context menu.

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