If you create a Slider, and drag it, things that have hover effects still get hover effects. The same thing goes for things like float fields. Demonstration:
That’s not what happens if you drag values on built-in components (that probably still use imgui):
Is this an intentional change, or a bug? I can work around it on my own components, but that’d require more hacking than I believe is worthwhile (remove all hover effects while dragging)
Not intentional but just something that’s non-trivial to “fix” and we didn’t get to it yet. The main reason for hover effects still working is because they don’t use events so even if an element has captured the mouse (and gets all events), hover still works.
The simplest workaround I’ve found was to temporarily create a single element on top of your entire Inspector, using Absolute position with left/right/top/left set to 0. Then making this “layer” element eat the mouse with
layerElement.pickingMode = PickingMode.Ignore;
You’re draggable element should still receive mouse events because it captured the mouse, even if it’s behind this layer element.
Hey, sorry to revive this thread, but seems like im not the sharpest tool here. How exactly should this workaround be applied?
I’m using Unity 2021.1.21f1 with UI Toolkit 1.0.0-preview18. I’m having this problem with vertical scroll view, when you’re dragging slider.dragElement to the bottom of the scrollbar fast enough and then release mouse button, and this dragElement stuck with mouse y-pos, scrolling up and down whereever mouse goes. And only unstuck when you click on any scrollbar element.
I’m not sure how to use this workaround. I’m creating new VisualElement with absolute position, 0,0,0,0 coordiantes, pickingMode set to ignore, sending it to back (visualElement.SendToBack())… and? How exactly should it be working? Do I need to do anything else?