Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Get a context menu on shape node (Read 4938 times)
Alok
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Dec 24th, 2013
Get a context menu on shape node
Dec 25th, 2013 at 5:29am
Print Post  
How to get context menu on a shape node using ASP.NET MVC ?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Get a context menu on shape node
Reply #1 - Dec 26th, 2013 at 11:05am
Print Post  
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:

Code
Select All
$get("diagram").oncontextmenu = function () { return false }; 



2. Add a NodeClicked event handler, e.g. from server

Code
Select All
diagramView.NodeClickedScript("onNodeClicked"); 



or from client side

Code
Select All
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/

Code
Select All
$.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:

Code
Select All
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
  
Back to top
 
IP Logged
 
liza
Full Member
***
Offline


I Love MindFusion!

Posts: 132
Joined: Apr 25th, 2019
Re: Get a context menu on shape node
Reply #2 - Apr 26th, 2019 at 6:19am
Print Post  
I tried the same but getting error $find is not a function. Please can you help me for the same?
  
Back to top
AIM  
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3253
Joined: Oct 19th, 2005
Re: Get a context menu on shape node
Reply #3 - Apr 26th, 2019 at 6:26am
Print Post  
$find is from MS Ajax mode. Otherwise you can find client side Diagram instance by setting var diagram = MindFusion.Diagramming.Diagram.find('your DiagramView ID');

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
liza
Full Member
***
Offline


I Love MindFusion!

Posts: 132
Joined: Apr 25th, 2019
Re: Get a context menu on shape node
Reply #4 - Apr 26th, 2019 at 9:11am
Print Post  
It worked. Thanks! Smiley
  
Back to top
AIM  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint