Hi,
There's no built-in support for context menus. You could use a third party library to create a menu and then show it from the NodeClickedScript function. You will also need to disable browser's own right click menu.
1. Disable the browser menu by setting the canvas oncontextmenu handler:
$get("diagram").oncontextmenu = function () { return false };
2. Add a NodeClicked event handler, e.g. from server
diagramView.NodeClickedScript("onNodeClicked");
or from client side
var diagram = $find("diagram");
diagram.addEventListener(MindFusion.Diagramming.Events.nodeClicked, onNodeClicked);
3. Create a context menu using this jQuery plugin for example:
http://plugins.jquery.com/contextMenu/ $.contextMenu({
selector: "#diagram",
trigger: "none",
callback: function (key, options)
{
if (key == "delete")
$find("diagram").removeItem(clickedNode);
},
items: {
"delete": { name: "Delete" }
}
});
4. Show the menu from NodeClicked handler:
var clickedNode;
function onNodeClicked(sender, args)
{
clickedNode = args.getNode();
if (args.getMouseButton() == 2)
{
var clientPt = $find("diagram").docToClient(args.getMousePosition());
$("#diagram").contextMenu(clientPt);
}
}
I hope that helps,
Stoyan