Cancel Drag & Drop with Esc Key

10 posts, 0 answers
  1. Lauren Nickerson
    Lauren Nickerson avatar
    52 posts
    Member since:
    Jul 2009

    Posted 29 Dec 2009 Link to this post

    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.
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 30 Dec 2009 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Lauren Nickerson
    Lauren Nickerson avatar
    52 posts
    Member since:
    Jul 2009

    Posted 30 Dec 2009 Link to this post

    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.
  5. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 04 Jan 2010 Link to this post

    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.
  6. Daniel Peterkin
    Daniel Peterkin avatar
    1 posts
    Member since:
    Feb 2010

    Posted 10 Feb 2010 Link to this post

    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
  7. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 15 Feb 2010 Link to this post

    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.
  8. Balaram Barange
    Balaram Barange avatar
    28 posts
    Member since:
    Apr 2009

    Posted 09 Mar 2010 Link to this post

    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.
  9. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 10 Mar 2010 Link to this post

    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.
  10. Balaram Barange
    Balaram Barange avatar
    28 posts
    Member since:
    Apr 2009

    Posted 10 Mar 2010 Link to this post

    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
     
  11. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 15 Mar 2010 Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready