Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How can you tell when a drag is canceled? (Read 1791 times)
David Cater
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: May 12th, 2012
How can you tell when a drag is canceled?
May 16th, 2012 at 5:38pm
Print Post  
I have a NodeListView and a Diagram.  I am dragging from the NodeListView to the Diagram.

I am trying to take some actions when a drag starts and when it finishes for any reason (drop or canceled drag). I catch the DragEntered event on the Diagram object to determine when the drag "starts" (although I have to be careful, because DragEntered can occur multiple times).

Is there any way to track the status of the drag to find out when it has finished?

Thanks,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can you tell when a drag is canceled?
Reply #1 - May 16th, 2012 at 5:53pm
Print Post  
Hi,

I think drag and drop from the NodeListView is always accepted by default, and you should get both Drop and NodeCreated events raised when the node is dropped. That should make the DragLeave event the only way to cancel.

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


I Love MindFusion!

Posts: 12
Joined: May 12th, 2012
Re: How can you tell when a drag is canceled?
Reply #2 - May 16th, 2012 at 7:43pm
Print Post  
The problem with that is that DragLeave will occur on the NodeListView when the mouse leaves the boundaries of the NodeListView, not when the drag is done.  And if you bring up a user interface over the diagram when it is dragged over (which is what I'm doing), the diagram will also get DragLeave.  In both of those cases, the drag is still going on.

I'll look at the source code for the drag and consider adding a static event of some sort that the Mindfusion code can raise when the drag is done.  That's what I've done with similar drag/drop code of my own in the past.  Then my code can hook that event (and a similar "DragStarted" event).

D.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can you tell when a drag is canceled?
Reply #3 - May 17th, 2012 at 6:00am
Print Post  
Now I see what do you mean. The drag is over when the DragDrop.DoDragDrop returns, but apparently there isn't any standard WPF event raised to indicate that. If you have the code, you can add a custom NodeListView event raised from OnPreviewMouseMove after the DragDrop.DoDragDrop(...) line. You will know the outcome of the drag operation from the DragDropEffect enum value returned by DoDragDrop - it should be either None or Copy.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint