Drag Drop operation and mouse position

2 posts, 0 answers
  1. Rajesh
    Rajesh avatar
    25 posts
    Member since:
    Dec 2007

    Posted 13 Jan 2010 Link to this post


    I am using Mindfusion control and using Telerik control Drag -Drop manager. Mindfusion control is used for diagraming stuff.
    It has following Hierachy
                         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.


  2. Miroslav
    Miroslav avatar
    922 posts

    Posted 15 Jan 2010 Link to this post

    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.

    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. DevCraft R3 2016 release webinar banner
Back to Top