Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved What's IDragHandler.OnDrag equivalent in UITK?

Discussion in 'UI Toolkit' started by RunninglVlan, Jul 16, 2021.

  1. RunninglVlan

    RunninglVlan

    Joined:
    Nov 6, 2018
    Posts:
    182
    I couldn't find
    IDragHandler.OnDrag
    equivalent yet, so I'm using
    PointerMoveEvent
    , but it works differently. OnDrag was called outside of element, but PointerMove works only on the element.
    BTW,
    PointerUpEvent
    isn't equivalent to
    IPointerUpHandler.OnPointerUp
    too. The latter was called outside of element too.
    Do the equivalent events exist in UITK? Because of this I'm creating additional elements under mouse now which I move and subscribe to to have equivalent functionality. I'd like not to do this.
     
  2. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    242
    If you want to receive
    PointerMoveEvent
    when outside of the element, you might want to
    CapturePointer
    during the
    PointerDownEvent
     
    RunninglVlan likes this.
  3. RunninglVlan

    RunninglVlan

    Joined:
    Nov 6, 2018
    Posts:
    182
    Thanks, didn't know about Capture events, it solved my issue!
    I just called
    element.CapturePointer(evt.pointerId)
    in
    PointerDownEvent
    handler and
    element.ReleasePointer(evt.pointerId)
    in
    PointerUpEvent
    handler
     
    Midiphony-panda likes this.