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

Cancel Drag & Drop with Esc Key

11 Answers 232 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Lauren Nickerson
Top achievements
Rank 1
Lauren Nickerson asked on 29 Dec 2009, 11:21 PM
Hello, I'm just wondering if this is possible out of the box through a setting. We want the user to be able to press Esc while dragging an object and have that cancel the dragging, just like in the Windows Explorer.

Thanks.

11 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 30 Dec 2009, 08:11 AM
Hello Lauren Nickerson,

this is the default behavior. Please check here:
http://demos.telerik.com/silverlight/#TreeView/FirstLook

Do you have an example where this do not work?

Kind regards,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Lauren Nickerson
Top achievements
Rank 1
answered on 30 Dec 2009, 07:23 PM
Actually I do... I replicated the code in a simplistic example and it works there, so I'm not really sure what's going on. Unfortunatelly I can't send you the project where it doesn't work as it is too big and it uses many other 3rd party resources. I'll try to find out what's going on. If you have an idea of what could cause the Esc to not work, please let me know so I could base my search on that.

Thanks.
0
Valentin.Stoychev
Telerik team
answered on 04 Jan 2010, 06:43 AM
Hello Lauren Nickerson,

Is there any chance that in your scenario the treeview is loosing the focus while you are dragging. If the focus is lost the keydown will not be handled and thus the Esc. key will not work.

Kind regards,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Daniel Peterkin
Top achievements
Rank 1
answered on 10 Feb 2010, 09:17 PM
Hi,

If the treeview does lose focus while the drag is in progress is it possible to cancel the delete? The current behaviour appear like a bug to the users.

Cheers,
Dan
0
Kiril Stanoev
Telerik team
answered on 15 Feb 2010, 09:53 AM
Hello Daniel,

For this particular scenario, you can attach to the LostFocus event of the TreeView and cancel the drag in there. One detail you have to keep in mind is to cancel the drag only of the newly focused element is not a child of the TreeView.

private void RadTreeView_LostFocus(object sender, RoutedEventArgs e)
{
    FrameworkElement focusedElement = FocusManager.GetFocusedElement() as FrameworkElement;
    RadTreeView parentTreeView = focusedElement.ParentOfType<RadTreeView>();
    if (parentTreeView == null)
    {
        RadDragAndDropManager.CancelDrag();
    }
}

I am attaching a sample project for further reference. Let me know if this an acceptable solution for your scenario.

Best wishes,
Kiril Stanoev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Balaram Barange
Top achievements
Rank 1
answered on 09 Mar 2010, 10:26 AM
Hi,
I want to cancel Drag & Drop on "ESC" key press, But i am losing focus on from the tree control. I don't know the reason of losing focus. Even i am unable to set the focus on Tree control in OnDropQuery Event. I capture the lostFocus Event of tree control and it is invoked when i change the selected the Tree Item.
0
Miro Miroslavov
Telerik team
answered on 10 Mar 2010, 04:47 PM
Hi Balaram Barange,

If press ESC while dragging from RadTreeView the drag is canceled and the focus stays on the RadTreeView. Can you please send us example project demonstrating your problem?

All the best,
Miro Miroslavov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Balaram Barange
Top achievements
Rank 1
answered on 10 Mar 2010, 05:08 PM
Hi,
I am dragged item inside the tree i.e. RadTreeViewItem. So focus is on RadTreeViewItem. RadTreeView's IsFocused property is false.

Thanks 
Balaram Barange
 
0
Miro Miroslavov
Telerik team
answered on 15 Mar 2010, 11:13 AM
Hi Balaram Barange,

Can you please find the attached example. Even when the RadTreeView is loosing the focus pressing the Esc still works and the dragging is Canceled for both examples with RadTreeView and ListBox.
The FocusLost is raised in the meantime of changing the selected item (the TreeView just gets the focus after the current selected item loses it and after that the newly selected gets the focus, so the TreeView loses it) . The only focused visual element in the focus scope is RadTreeViewItem (the selected one), that's why the TreeView iteself can't be focused too.
Can you please reproduce your problem and send us back the example, so we can examine it?

Kind regards,
Miro Miroslavov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
shashank
Top achievements
Rank 1
answered on 31 Oct 2018, 08:25 PM

When we press Esc while dragging what event and where we will get so that I can handle the cancel.

As when start dragging am setting some property and if user press ESC want to reset those but am not getting any event.

Also is there a way to remove the Esc option.

0
Dinko | Tech Support Engineer
Telerik team
answered on 05 Nov 2018, 12:36 PM
Hello Shashank,

You can subscribe to the QueryContinueDrag event of the RadTreeView. You can use the EscapePressed to check if the Esc button is pressed. But keep in mind that still, the default behavior which is canceling the dragging while this button is pressed can be overridden.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeView
Asked by
Lauren Nickerson
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Lauren Nickerson
Top achievements
Rank 1
Daniel Peterkin
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Balaram Barange
Top achievements
Rank 1
Miro Miroslavov
Telerik team
shashank
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or