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

Drag Drop operation and mouse position

1 Answer 125 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Rajesh
Top achievements
Rank 1
Rajesh asked on 13 Jan 2010, 02:05 PM
Hi

I am using Mindfusion control and using Telerik control Drag -Drop manager. Mindfusion control is used for diagraming stuff.
It has following Hierachy
              Diagram
                     Node ( Can be shapenode, Table node, container)
                  
 With normal shape node, using Drag-drop manager is possible. It is also possible to use Drag-Drop manger with Table nodes and container nodes.

The problem I have, Table node has one more hierachy data i.e CellItem and one can have table with rows and columns. I am able to make drag-drop operation of table node. In this case table node has function which returns me the cell row, col if I pass the point (mouse position).

With Telerik DragDrop, my sender object is "Diagram" Control and I need mouse postion which is relative to either diagram or tablenode. The mouse position avaiable in options ( CurrentDragPoint and MouseClick Point have almost same value) are not relative to either diagram or table node. How I calcuate it relative to either one of the element so i get correct row and column in tablenode.

Regards
Rajesh

1 Answer, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 15 Jan 2010, 04:59 PM
Hi Rajesh,

Yes, you are right that the two points are not relative but absolute.

You can get the relative coordinates of the mouse to the diagram element by finding its absolute position and then substracting them, like so:

var topLeftOfDiagramElement = diagramElement.TransformToVisual(null).Transform(new Point());
var relativeMouseX = e.Options.CurrentDragPoint.X -  topLeftOfDiagramElement.X;
var relativeMouseY = e.Options.CurrentDragPoint.Y -  topLeftOfDiagramElement.Y;


We are planning to add another property that will give you the relative position with regard to the destination, it is expected to appear for 2010.Q1.

Regards,
Miroslav
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.
Tags
DragAndDrop
Asked by
Rajesh
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Share this question
or