Search Unity

What causes clicks to cancel when dragging?

Discussion in 'UGUI & TextMesh Pro' started by Deleted User, Oct 5, 2018.

  1. Deleted User

    Deleted User

    Guest

    For some buttons, dragging the mouse after you press, but before you release, will cancel the click operation on that button. At first, I thought the ScrollRect was responsible for canceling the click, but after looking at the ScrollRect and Button sources, I can't figure out what's doing it.

    So what mechanism is responsible for cancelling clicks when the cursor is dragged?

    Thanks
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    That decision is presumably handled at the level of the EventSystem.

    The EventSystem has a "drag threshold" property that determines the minimum distance the mouse has to move in order for an action to be considered a "drag" rather than a "click".

    But in addition to that, if there are no objects in the object hierarchy being clicked that have defined drag handlers, then I believe the action can count as a click even if the mouse movement exceeds this threshold, as long as the pointerDown and pointerUp events both happen within the bounds of the button.