That sample’s single context menu button when clicked creates a node and draws a link to it from the original node. But of course your context menu buttons can do whatever you want.
Thank you @walter, your example really helped. I was able to create a new context menu and add menu items dynamically.
One more thing I noticed in the example. Regular context menu will hide itself when you click outside if it or press escape key. But this new CM from example will hide only if you leave it’s area or if you click on the menu item. You can see this part of the code
var cm =
$("ContextMenu",
{
//background: "transparent",
//padding: 10,
mouseLeave: function (e, obj) { tool.hideContextMenu(); }
},
I want it to behave as usual, but if I remove the mouseLeave line then it always stays opened. How do I make it behave as usual?
That works when I click on diagram. But if I click on any other node or object it will not respond to click event. Also escape key is also not hiding CM. Do I really need to subscribe to every event to make it work?
OK, I guess having the complete behavior of ContextMenuTool is a reasonable expectation. So I have reimplemented (and simplified) Page Not Found -- Northwoods Software. Please force a reload and look at the new code.