Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Unable to use Select Multiple nodes and Draw links behaviour both at a time? (Read 155 times)
Avinash
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 22
Joined: Nov 12th, 2024
Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Jan 24th, 2025 at 6:20am
Print Post  
I have a requirement where i should to select multiple nodes through mouse select and drag to delete or move, and should be able to draw links between nodes.

If i use this i can achieve everything except drawlinks
this.diagramView.behavior = Diagramming.Behavior.Modify;

If i use this also, i can drawlinks but unable to select multiple nodes using mouse.
this.diagramView.behavior = Diagramming.Behavior.DrawLinks;

How can i achieve both functionality using which behaviour?

And i have attached Screenshot where my diagram is inside container, when am selecting multiple nodes using mouse even Container also auto selecting, how to avoid container while selecting multiple nodes.



  

image__3_.png ( 66 KB | 14 Downloads )
image__3_.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Reply #1 - Jan 24th, 2025 at 9:55am
Print Post  
Drawing selection works in DrawLinks behavior when no items under the mouse pointer, but a pointed container would allow drawing links by default. Set container.allowOutgoingLinks = false to prevent the links and draw selection lasso instead. To prevent selecting the container, handle nodeSelecting event:

Code
Select All
diagram.nodeSelecting.addEventListener(
    (s, e) =>
    {
        if (e.node instanceof ContainerNode)
            e.cancel = true;
    }); 



Regards,
Slavcho
Mindfusion
  

Containers_001.zip ( 970 KB | 14 Downloads )
Back to top
 
IP Logged
 
Avinash
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 22
Joined: Nov 12th, 2024
Re: Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Reply #2 - Jan 27th, 2025 at 11:44am
Print Post  
Thanks Container selection is not happening now, but now i have set behaviour to this.

   this.diagramView.behavior = Diagramming.Behavior.DrawLinks;
    this.diagramView.allowMultipleSelection = true;
    this.diagramView.allowSelfLoop = false;


Where should add this  container.allowOutgoingLinks = false, is it to be set to diagramview?
  
Back to top
 
IP Logged
 
Avinash
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 22
Joined: Nov 12th, 2024
Re: Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Reply #3 - Jan 27th, 2025 at 11:51am
Print Post  
I have set it as

// Set allowOutgoingLinks = false for all container nodes
    this.diagram.nodes.forEach((node: any) => {
      if (node instanceof ContainerNode) {
        node.allowOutgoingLinks = false;
      }
    });

But still Selection is not working, and container links are working
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Reply #4 - Jan 27th, 2025 at 12:54pm
Print Post  
Make sure that code runs after all containers are created. If you let users draw new containers, you could set the property from nodeCreated event.
  
Back to top
 
IP Logged
 
Avinash
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 22
Joined: Nov 12th, 2024
Re: Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Reply #5 - Jan 28th, 2025 at 7:36am
Print Post  
diagram.nodeSelecting.addEventListener(
    (s, e) =>
    {
        if (e.node instanceof ContainerNode)
            e.cancel = true;
    });

This event making complete disable of container, now am unable to resize it , not select it.  my requirement only while selecting multiple nodes inside container, container should not be selected by default.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Reply #6 - Jan 28th, 2025 at 11:24am
Print Post  
You'll have to access some internals to know if the event is raised because of selection lasso:

Code
Select All
var CreateSelectionController = MindFusion.Diagramming.CreateSelectionController;

diagram.nodeSelecting.addEventListener(
    (s, e) =>
    {
        // prevent container selection when drawing lasso
        var mouseHandler = diagramView.mouseInputDispatcher;
        if (mouseHandler.anyController(
            c => c instanceof CreateSelectionController))
        {
            if (e.node instanceof ContainerNode)
                e.cancel = true;
        }
    }); 



Or alternatively handle SelectionChanged event instead, which is raised once after selection arrays are updated, and remove container from selection when latter contains more than one node.

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


I Love MindFusion!

Posts: 22
Joined: Nov 12th, 2024
Re: Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Reply #7 - Jan 28th, 2025 at 11:42am
Print Post  
Yah thanks , conntainer selection is working now, and not selecting in multi select nodes.

But can you guide me how to set container.allowOutgoingLinks = false, while am using behaviour only as "DrawLinks".

My only requirement is i should able to drawlinks and select multiple node to Delete.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Reply #8 - Jan 28th, 2025 at 11:59am
Print Post  
There's nothing needed other than setting allowOutgoingLinks to false immediately after creating container, as shown in the test script attached a few posts above. Check if that's not getting reset back to true by a different part of the application. If you are letting users draw containers interactively, you'll need to set the property from nodeCreated event handler. If you are loading diagram data asynchronously, make sure you run that loop after data arrives and the diagram is populated.

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


I Love MindFusion!

Posts: 22
Joined: Nov 12th, 2024
Re: Unable to use Select Multiple nodes and Draw links behaviour both at a time?
Reply #9 - Jan 29th, 2025 at 4:39am
Print Post  
Perfect thanks Slavcho, it's Working.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint