Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Drag node out of diagram (Read 2770 times)
karenm
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 6th, 2009
Drag node out of diagram
Apr 27th, 2010 at 5:53am
Print Post  
Hello,

I have a diagram with RestrictItemsToBounds = InsideOnly. When a node is dragged outside of the diagram and the mouse released, the node and its links snap back to its original location (as expected).

The node being dragged has a number of related nodes:
1) Attached nodes that are part of a group; and
2) Linked nodes that are joined via links.

When the drag is "cancelled" by dragging out of bounds, the attached nodes do not go back to the original position (and so now are displaced from the master node).

I have it such that the linked nodes are "animated" so that they trail the dragged node around the diagram while it is being dragged. This means that when the dragged node snaps back to its original position, the linked node(s) are still at their new positions instead of being returned to the original position (like the dragged node is). This results in the links between the dragged node and the linked node(s) seeming to be pointing at nothing - but they link up again as soon as I try dragging the original node again.

Do you have any tips for how I might be able to control this scenario a little better? My main aims would be to have the attached nodes in the same relative position to the dragged node and for the links to be aligned to the linked nodes instead of hanging in mid-air after the drag is "cancelled". I don't mind particularly whether the linked nodes return to their original position or not, I'd just like the link end points to appear correctly.

I tried handling the NodeModifyCancelled event to perform some arrange/move operations on the attached/linked nodes but this event doesn't seem to fire in this scenario.

Thanks for any advice you can offer.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag node out of diagram
Reply #1 - Apr 27th, 2010 at 10:23am
Print Post  
I can't reproduce this in the Demo/Misc/Groups sample, so I suppose your animation code has the last word on the nodes' positions. NodeModifyCancelled seems the right event to handle to return the animated nodes to their proper place, and I can see it's raised in this case too. However it fires only for the master node - did you expect it to fire for the attached nodes?
  
Back to top
 
IP Logged
 
karenm
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 6th, 2009
Re: Drag node out of diagram
Reply #2 - Apr 27th, 2010 at 11:06pm
Print Post  
No, I didn't, but it doesn't fire at all, not even for the node I'm dragging (i.e. the one dragged out of bounds).

I will review the sample to see if I can work out what is different.
  
Back to top
 
IP Logged
 
karenm
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 6th, 2009
Re: Drag node out of diagram
Reply #3 - Apr 28th, 2010 at 2:28am
Print Post  
OK, I was doing something silly that prevented the event from firing. Now it is firing, I should be able to try a few more things.

I have some code in my NodeModifying event that arranges the diagram using a spring layout (using BeginArrange). If I comment that out, the behaviour is as expected but then I lose my animation.

There is some processing related to the animation in the NodeModified event handler that resets some private variables, so I suspect that doing something similar in NodeModifyCancelled may resolve the issue.

Update - I now have the links displaying correctly (by re-calling Arrange in NodeModifyCancelled), but the grouped nodes still are displaced from the main node...
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag node out of diagram
Reply #4 - Apr 28th, 2010 at 5:44am
Print Post  
Are you animating the attached nodes too? I suppose the code that places them at their final position relative to the group master in response to NodeModified could be also used in NodeModifyCancelled then ...
  
Back to top
 
IP Logged
 
karenm
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 6th, 2009
Re: Drag node out of diagram
Reply #5 - Apr 29th, 2010 at 11:31pm
Print Post  
No, only the main node.  I have KeepGroupLayout = true on the spring layout and when I do a normal arrange (i.e. just by calling the Arrange method) the attached nodes are in the correct positions after the arrange.

There is no code in the NodeModified event that repositions the attached nodes - the layout algorithm just takes care of it automatically in this case.

But I put some code that repositions the attached nodes into NodeModifyCancelled, so I at least have a workaround, but it seems a little strange that this is required.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint