ContextMenuTool class

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

Define context menus on individual GraphObjects by setting GraphObject#contextMenu. Define a context menu for the diagram background by setting Diagram#contextMenu.

This tool is a standard mouse-down tool, the ToolManager#contextMenuTool.

This tool does not utilize any tool handles. This tool does not modify the model or conduct any transaction, although any code invoked by context menu commands might do so.

There are examples of customizing this tool in the Custom Context Menu and HTML LightBox Context Menu samples.

If you want to programmatically show a context menu for a particular GraphObject or for the whole diagram, call CommandHandler#showContextMenu. That command method is also invoked by the Menu key on the keyboard.

Normally this shows a context menu (if available) on a right-mouse-up event. If you want it to happen on a right-mouse-down event, you'll need to move this tool from the ToolManager#mouseUpTools list to the ToolManager#mouseDownTools list:

myDiagram.toolManager.mouseDownTools.add(myDiagram.toolManager.replaceTool("ContextMenu", null));
Implemented types
Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

ContextMenuTool()
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited