Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Listen to mouse events outside element

Discussion in 'UI Toolkit' started by Knosis_Co-Verse, Apr 24, 2021.

  1. Knosis_Co-Verse

    Knosis_Co-Verse

    Joined:
    Apr 23, 2019
    Posts:
    12
    I'm trying to create a behavior similar to the built-in sliders, where once you start to change it, you can move your cursor anywhere in the monitor and the slider will still keep track of it.
    All the mouse events seems to only be triggered once the mouse is inside the bounding box of the element (make sense but), is there a way to change this behavior?

    And while I'm here... I'm trying to use ChangeEvent in a custom VisualElement and I'm really struggling. Tried to implement INotifyValueChange hoping for some magic, didn't help, also tried registering/creating/sending ChangeEvents in multiples ways, no luck.
    Currently I just have a Action field in the element. Works, a bit ugly tho.
     
    Last edited: Apr 24, 2021
  2. AlainL_Unity

    AlainL_Unity

    Unity Technologies

    Joined:
    Apr 6, 2021
    Posts:
    6
    Hi,

    The behavior you are trying to implement will be supported out of the box in a future version. There is currently a known issue with pointer capturing in runtime builds not behaving as expected, i.e. losing events when outside of the element’s bounding box. A fix will be made available soon in a 2021.2 alpha and will also be backported to the package version of UI Toolkit later.

    About your second topic - could you provide more details about what you are trying to achieve? Here’s a link that might help: https://forum.unity.com/threads/fire-typeless-changeevent.785492/

    Regards,
    Alain