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

Mouse position on drop

3 Answers 104 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Nikituki
Top achievements
Rank 1
Nikituki asked on 10 Feb 2012, 09:18 AM
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?

3 Answers, 1 is accepted

Sort by
0
Nikituki
Top achievements
Rank 1
answered on 13 Feb 2012, 09:40 AM
up
0
Tina Stancheva
Telerik team
answered on 15 Feb 2012, 10:17 AM
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 >>
0
Nikituki
Top achievements
Rank 1
answered on 15 Feb 2012, 11:58 AM
Thx,

but your example doesn't work. The correct code:
RadDragAndDropManager.AddDropInfoHandler(RadTreeView, new EventHandler<DragDropEventArgs>(OnDropInfo));
Tags
TreeView
Asked by
Nikituki
Top achievements
Rank 1
Answers by
Nikituki
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or