Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Anchor Point Link Connection (Read 1489 times)
SAN
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 11
Joined: Feb 29th, 2024
Anchor Point Link Connection
Sep 26th, 2024 at 10:23am
Print Post  
I have a node with 4 anchor points. Can I Restrict to link once for one anchor?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Anchor Point Link Connection
Reply #1 - Sep 26th, 2024 at 12:12pm
Print Post  
Try handling the validateAnchorPoint event:

Code
Select All
diagram.addEventListener(Events.validateAnchorPoint, onValidateAnchorPoint);

function onValidateAnchorPoint(sender, args)
{
    var outLinks = args.node.outgoingLinks;
    var inLinks = args.node.incomingLinks;
    args.cancel =
        outLinks.some((l) => l.originAnchor == args.anchorIndex) ||
        inLinks.some((l) => l.destinationAnchor == args.anchorIndex);
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
SAN
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 11
Joined: Feb 29th, 2024
Re: Anchor Point Link Connection
Reply #2 - Sep 27th, 2024 at 7:55am
Print Post  
I am using version 3.5.7. Any workaround for that as this event is not part of the version
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Anchor Point Link Connection
Reply #3 - Sep 27th, 2024 at 8:45am
Print Post  
I guess you could reattach to a different anchor point from linkCreated event handler. Count all links that connect to same origin node / originAnchor and destination node / destinationAnchor pairs as the new link. If you find older links connecting to same points, reset originAnchor and / or destinationAnchor of new link to connect them to unused points.
  
Back to top
 
IP Logged
 
SAN
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 11
Joined: Feb 29th, 2024
Re: Anchor Point Link Connection
Reply #4 - Sep 27th, 2024 at 11:29am
Print Post  
Is there a possibility of cancelling the event all together for the new link creation. something like eventArgs.setcancel() if the destination anchor points for the links are the same
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Anchor Point Link Connection
Reply #5 - Sep 30th, 2024 at 7:22am
Print Post  
You can cancel from linkCreating event handler. There's an internal anchorPointDetails object shown in use here -

https://mindfusion.eu/Forum/YaBB.pl?num=1524153022/1#1

and it also contains an index field specifying the point index.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint