This is a migrated thread and some comments may be shown as answers.

How to cancel drop after user prompt

3 Answers 88 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Eli Schleifer
Top achievements
Rank 1
Eli Schleifer asked on 13 Jul 2009, 03:49 PM
I would like to provide a drag drop mechanism where after the mouse is released over the target (indicating the drop shuld proceed) I can prompt the user with a messagebox say - Drop Here? And allow the user to cancel the action. What events/methods should I be keyeing off of to achieve this.

Thanks

3 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 13 Jul 2009, 05:23 PM
Hi Eli Schleifer,

Given that you have the rest of the DragDrop working (I could help you with this if you need), then you will most probably be doing something in the DragInfo handler with DragComplete status, lets say removing the item from the source object. Then probably you will be adding the dragged item(s) in the DropInfo handler  - with DropComplete status.

What you could do is build an object that has delegates pointing to anonymous functions that do what you will normally do in the Drag/Drop info handlers. You can build this object in the Drag/Drop handlers and remember this object somewhere (also as a payload of the DragDrop). Then on drop info you show the user prompt and execute the actions only if they were confirmed. I suggested lambda (anonymous) functions because you could easily transform existing code into them, of course you could approach it differently.

Implementing this may not be trivial so please come back to us if you need an example or more clarification.

Best wishes,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Eli Schleifer
Top achievements
Rank 1
answered on 13 Jul 2009, 07:39 PM
From what I can tell the OnDropInfo event is fired frequently even while just hovering over a drop area...which is why I sent out this inquiry. I don't see any specific status code from the time of doppossible to dropcomplete or a wat to cancel the Drop once DropComplete Info is sent.

If you could put together a small sample that would be much appreciated.

Thanks
Eli
0
Miroslav
Telerik team
answered on 15 Jul 2009, 07:24 AM
Hi Eli,

Yes, I created an example and I have attached it to this reply.

Please note that the sample implementation is aimed at reducing the code change from an existing drag-drop implementation. You just need to change the payload with a custom class, wrap the current drag/drop info handlers in actions and make sure you use the new payload.

Certainly there can be other implementations but I hope this one is simple and easy to use.

Hopefully you will be able to use the example,

All the best,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
DragAndDrop
Asked by
Eli Schleifer
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Eli Schleifer
Top achievements
Rank 1
Share this question
or