Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to Create a Node when the Canvas is clicked (Read 480 times)
alukes
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 61
Joined: Jul 1st, 2011
How to Create a Node when the Canvas is clicked
Jun 28th, 2023 at 12:23pm
Print Post  
I can get the context menu to appear at the correct location using the code below.

When I use point.x and point.y to create a node, the node is far away from where the canvas was clicked. How do I get the node to appear where the canvas was clicked?


function onClicked(sender, args) {

var point = diagramView.docToClient(args.mousePosition);

contextMenu.style.display = "block";
           contextMenu.style.left = `${point.x}px`;
           contextMenu.style.top = `${point.y}px`;
}
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3156
Joined: Oct 19th, 2005
Re: How to Create a Node when the Canvas is clicked
Reply #1 - Jun 28th, 2023 at 3:25pm
Print Post  
Create it at the original args.mousePosition reported for the event. It's specified in diagram's measureUnit, which is used for item coordinates too. You need the converted point only for menu DIV's pixel offset.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
alukes
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 61
Joined: Jul 1st, 2011
Re: How to Create a Node when the Canvas is clicked
Reply #2 - Jun 28th, 2023 at 7:34pm
Print Post  

Thanks for the explanation.

It works
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint