Class ContextMenuTool
Extends Tool. 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.
Constructor Summary Details
Returns | Name | Description |
---|---|---|
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. More...
The Tool.name of this tool is "ContextMenu". |
Properties Summary Details
Returns | Name | Description |
---|---|---|
currentContextMenu
|
Gets or sets the currently showing context menu, or null if there is none. More...
This is typically only set in showContextMenu and not by the user.
It is also typically set to null in hideContextMenu.
|
|
currentObject
1.4
|
Gets or sets the GraphObject found at the mouse point that has a context menu. More...
This property remembers the result returned by findObjectWithContextMenu if it is a GraphObject.
This value is passed to showContextMenu as the second argument.
The value will be null if the context menu is for the diagram rather than for a particular GraphObject.
|
|
{Point}
|
mouseDownPoint
|
This read-only property returns the original mouse-down point in document coordinates.
|
Method Summary Details
Returns | Name | Description |
---|---|---|
{boolean}
|
canStart()
|
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. More...
This is also true if the mouse right click is in the diagram background
and the diagram's Diagram.contextMenu is non-null.
On touch devices, a special default context menu will appear even if no object with a context menu is found. This method may be overridden.
|
doActivate()
|
Do nothing, activation is special and relies on doMouseUp
|
|
doMouseMove()
|
Handle mouse-enter, mouse-over, and mouse-leave events.
|
|
doMouseUp()
|
If there is something found by findObjectWithContextMenu,
call showContextMenu with that object's GraphObject.contextMenu
or the Diagram.contextMenu. More...
If nothing is found or there is no context menu, call showDefaultContextMenu.
Once a context menu is being shown, if a click occurs on a part of the context menu, call Tool.standardMouseClick. Otherwise if the click occurs elsewhere, just stop this tool. Unlike most tools, the first mouse-up should not stop this tool. |
|
findObjectWithContextMenu(obj)
|
Find a GraphObject at the current mouse point with a GraphObject.contextMenu,
or return the Diagram if there is a Diagram.contextMenu. More...
This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.
|
|
hideContextMenu()
|
Hide any context menu. More...
This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method. |
|
hideDefaultContextMenu()
|
Hide the default context menu. More...
This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method. |
|
positionContextMenu(contextmenu, obj)
|
This is called by showContextMenu to position the context menu within the viewport. More...
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 context menu, an Adornment, does not have a Adornment.placeholder. When there is a Placeholder in the context menu, 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 context menu, the context menu has already been measured but not arranged, so you can use its GraphObject.measuredBounds width and height but not its GraphObject.actualBounds.
|
|
showContextMenu(contextmenu, obj)
|
Show an Adornment as a context menu. More...
If the object's containing Part is data-bound,
set the contextmenu's This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.
|
|
showDefaultContextMenu()
|
Show a series of HTML elements acting as a context menu. More...
If the object's containing Part is data-bound,
set the contextmenu's On touch devices, a special default context menu will appear even there is no context menu defined. This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method. |
- Methods borrowed from class Tool:
- cancelWaitAfter, canStartMultiTouch, doCancel, doDeactivate, doKeyDown, doKeyUp, doMouseDown, doMouseWheel, doStart, doStop, doWaitAfter, findToolHandleAt, isBeyondDragSize, standardMouseClick, standardMouseOver, standardMouseSelect, standardMouseWheel, standardPinchZoomMove, standardPinchZoomStart, standardWaitAfter, startTransaction, stopTool, stopTransaction, updateAdornments