Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Drag and Drop onto links (Read 3194 times)
jonsberndt
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Sep 18th, 2008
Drag and Drop onto links
Sep 24th, 2008 at 10:39pm
Print Post  
Is there a way to detect and handle when an object is dropped onto a link?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag and Drop onto links
Reply #1 - Sep 25th, 2008 at 6:52am
Print Post  
Handle the NodeModified event, call view.ClientToDoc(view.PointToClient(MousePosition)) to get the mouse pointer position in the diagram coordinate system, and finally call GetLinkAt() to find out if there is a link there. Additionally, take a look Workflow Designer sample - it handles drag-and-drop of listbox items onto links.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jonsberndt
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Sep 18th, 2008
Re: Drag and Drop onto links
Reply #2 - Oct 2nd, 2008 at 11:04am
Print Post  
Stoyo wrote on Sep 25th, 2008 at 6:52am:
Handle the NodeModified event, call view.ClientToDoc(view.PointToClient(MousePosition)) to get the mouse pointer position in the diagram coordinate system, and finally call GetLinkAt() to find out if there is a link there. Additionally, take a look Workflow Designer sample - it handles drag-and-drop of listbox items onto links.

I hope that helps,
Stoyan


This is sort of working for me, but I'm having a hard time with getting the location correct when scrolling is involved. It seems to me that DocToClient() returns 0,0 even when it is passed non-zero document locations.

Jon
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag and Drop onto links
Reply #3 - Oct 2nd, 2008 at 12:27pm
Print Post  
You should not call DocToClient but ClientToDoc. The static Conrol.MousePosition property gives you the mouse location in screen coordinates. Calling view.PointToClient(MousePosition) returns the mouse coordinates relative to the view. Finally, ClientToDoc returns the document coordinates which you can pass to GetLinkAt.

I've just seen there is a MousePosition property of NodeEventArgs which should give you the mouse position directly in document coordinates, so you wouldn't need those conversions if you use it instead of Control.MousePosition.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jonsberndt
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Sep 18th, 2008
Re: Drag and Drop onto links
Reply #4 - Oct 3rd, 2008 at 4:44am
Print Post  
Stoyo wrote on Oct 2nd, 2008 at 12:27pm:
You should not call DocToClient but ClientToDoc. The static Conrol.MousePosition property gives you the mouse location in screen coordinates. Calling view.PointToClient(MousePosition) returns the mouse coordinates relative to the view. Finally, ClientToDoc returns the document coordinates which you can pass to GetLinkAt.

I've just seen there is a MousePosition property of NodeEventArgs which should give you the mouse position directly in document coordinates, so you wouldn't need those conversions if you use it instead of Control.MousePosition.

I hope that helps,
Stoyan


The question remains,however, how do I get this to work with scrolling? That's not clear to me.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag and Drop onto links
Reply #5 - Oct 3rd, 2008 at 10:09am
Print Post  
You shouldn't have to do anything special to make it work with scrolling. NodeEventArgs.MousePosition returns the mouse position in diagram coordinates, relative to the top-left of the whole document. Same if you are using ClientToDoc - it applies both the scroll position and zoom factor values to the converted coordinates.
  
Back to top
 
IP Logged
 
jonsberndt
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Sep 18th, 2008
Re: Drag and Drop onto links
Reply #6 - Oct 3rd, 2008 at 11:06am
Print Post  
Stoyo wrote on Oct 3rd, 2008 at 10:09am:
You shouldn't have to do anything special to make it work with scrolling. NodeEventArgs.MousePosition returns the mouse position in diagram coordinates, relative to the top-left of the whole document. Same if you are using ClientToDoc - it applies both the scroll position and zoom factor values to the converted coordinates.


Thanks. As it turns out, my biggest problem when dropping a node on a link was that the link would re-route when I dropped the node - which changes the parameters so the new node is not inserted as desired. So, I need to work around that - to make sure that the link doesn't change when I don't want it to.

Jon
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag and Drop onto links
Reply #7 - Oct 5th, 2008 at 8:26am
Print Post  
If you set Node.Obstacle = false, e.g. in the NodeStartModifying event handler, the links will not be re-routed when the node is dropped. Then you could set Obstacle back to true in the Modified event. Another way to do that is to temporarily set TriggerRerouting to Never.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jonsberndt
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Sep 18th, 2008
Re: Drag and Drop onto links
Reply #8 - Oct 5th, 2008 at 12:19pm
Print Post  
Stoyo wrote on Oct 5th, 2008 at 8:26am:
If you set Node.Obstacle = false, e.g. in the NodeStartModifying event handler, the links will not be re-routed when the node is dropped. Then you could set Obstacle back to true in the Modified event. Another way to do that is to temporarily set TriggerRerouting to Never.

I hope that helps,
Stoyan


Yes, that all seems to work, now. Thanks!

Jon

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