Start drag on control when mouse leaves control

2 posts, 0 answers
  1. Eli Schleifer
    Eli Schleifer avatar
    5 posts
    Member since:
    Jul 2009

    Posted 13 Oct 2009 Link to this post

    We have a scenario where we would like to delay dragging while the user is clicking and moving mouse inside a control, but if the mouse is still down when the mouse leaves the control, to fire the drag event then. We have a basic workaround where we will check the mouse poisition and as the mouse approaches the edge of the control we will start the drag, but this is not 100% effective as fast mouse movements will not trigger additional dragqueries.

    Is there any way to solve this issue?

  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 16 Oct 2009 Link to this post

    Hello Eli,

    I am sorry for the delayed reply, we were busy with the Beta 2 release of the controls which should be available for download now.

    Unfortunately I cannot offer a workaround with the SP1 version of the controls (2009.2 812)

    In the internal builds (and in the beta) the DragAndDropManager has the StartDrag() method and here is how you can use it:

    1. Register for the MouseLeftButtonDown and Up events on the root visual (root page of your application). Use the rootPage.AddHandler(event, handler, true); method to register for the event. This way you will be notified for the event even if is handled. This way you will know if the mouse is pressed or not.

    2. Register for the MouseLeave event on the particular control

    3. In the MouseLeave handler check if the mouse is pressed and start dragging using the StartDrag method on the DragAndDrop manager.

    There really is no guarantee whether the mouse move event (and therefore the drag/drop events) will be called if the user moves the mouse quickly, so I cannot think of another workaround.

    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.
  3. DevCraft banner
Back to Top