Mouse position on drop

4 posts, 0 answers
  1. Nikituki
    Nikituki avatar
    34 posts
    Member since:
    Nov 2011

    Posted 10 Feb 2012 Link to this post

    I'm trying to get mouse cursor position when item droping in treeview.
    I use DragOverTree event, but ExternalDragEventArgs always null.
    DragOver event never rising.

    How else can I get mouse position?
  2. Nikituki
    Nikituki avatar
    34 posts
    Member since:
    Nov 2011

    Posted 13 Feb 2012 Link to this post

    up
  3. DevCraft banner
  4. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 15 Feb 2012 Link to this post

    Hello Nikituki,

    In order to implement your scenario it is best to handle the RadDragAndDropManager.DragInfoEvent or RadDragAndDropManager.DropInfoEvent. Since the RadTreeView implementation internally uses the DragDropManager, all drag/drop related events of the manger will be triggered by the RadTreeView control.

    The RadDragAndDropManager.DragInfoEvent can give you information about the drag in progress thus allowing you to track the CurrentDragPoint which you can access through the DragDropEventArgs. Or if you only need to get the CurrentDragPoint when a drop operation is complete then you can handle the RadDragAndDropManager.DropInfoEvent. In the event handler you can check if the status of the operation is DropComplete and then get the CurrentDragPoint coordinates.

    You can attach event handlers to both events like so:
    this.AddHandler(RadDragAndDropManager.DragInfoEvent, new EventHandler<DragDropEventArgs>(OnDragInfo));
    this.AddHandler(RadDragAndDropManager.DropInfoEvent, new EventHandler<DragDropEventArgs>(OnDropInfo));

    And then you can implement such a logic for getting the drag point coordinates:
    private void OnDragInfo(object sender, DragDropEventArgs e)
    {
        var doppedPosition = e.Options.CurrentDragPoint;
    }
    private void OnDropInfo(object sender, DragDropEventArgs e)
    {
        if (e.Options.Status == DragStatus.DropComplete)
        {
            var doppedPosition = e.Options.CurrentDragPoint;
        }
    }

    Please give this a try and let me know if it helps.

    Regards,
    Tina Stancheva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  5. Nikituki
    Nikituki avatar
    34 posts
    Member since:
    Nov 2011

    Posted 15 Feb 2012 Link to this post

    Thx,

    but your example doesn't work. The correct code:
    RadDragAndDropManager.AddDropInfoHandler(RadTreeView, new EventHandler<DragDropEventArgs>(OnDropInfo));
Back to Top