Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Mouse Coordinates on Drop
posted

I've been working with the new drag and drop framework for a little while now.  Currently I have a need for the mouse coordinates whenever the item is dropped.  Normally I would just throw a onmouseup event and grab the coordinates that way.  However, for some reason that event never fires when I have a drag and drop item attached to the mouse.  

Also I tried using evntArgs.get_x() and evntArgs.get_y() from inside the DropHandler method.  This threw the Object doesn't support this property or method error.

function dropHandler(source, evntArgs)

{   

            var tmpx = evntArgs.get_x();

            var tmpy = evntArgs.get_y();

}

 

Any help here would be much appreciated.  Thank you for your time.

  • 130
    posted

    Thank you for your reply.  It worked like a charm.

  • 24497
    Verified Answer
    posted

    Hi Arithal,

    The drop handler contains instance of DragDropEventArgs as 2nd param. That class has get_manager() member function. The get_x/y are available in drag-move events.

    If you need those values within drop handler, then I can suggest to set global members within move and get them within drop. Example:

    var my_dragX = null;
    var my_dragY = null;
    function dragMoveHandler(source, evntArgs)
    {
     my_dragX = evntArgs.get_x();
     my_dragY = evntArgs.get_y();
    }
    function dropHandler(source, evntArgs)
    {  
     alert('x/y=' + my_dragX + ':' + my_dragY);
    }