Context menu


Is there any way to detect whether context menu is open or close?

myDiagram.toolManager.contextMenuTool.currentContextMenu !== null

I have an event that fires when I click outside canvas, how can I close context menu from there?

If the context menu was shown by the ContextMenuTool’s running, then you can interrupt its operation the same way you can all Tools: myDiagram.currentTool.doCancel()

If you called ContextMenuTool.showContextMenu, I suppose you can call hideContextMenu.

When I open context menu and diagram is center aligned, diagram shifts upward. Any suggestion on this?

I’m not sure what you mean. I cannot reproduce any such behavior in the Basic sample, which has context menus defined on Nodes, Links, and the Diagram background.