I’m hugely frustrated by the following problem, which I’ve struggled to find a solution to for a few months now.
Basically, I have a ListBox component, containing buttons and other controls.
What I want, is that while once the listbox’s ViewPort has started moving due to dragging (by dragging), the controls in the ListBox should become inactive until the ListBox has stopped scrolling. Otherwise, for example, if I (say) tap a button, and use that to drag the ListBox, when the button is released - it activates.
Have you tried setting the viewportIgnoreDragFlag on the ListBox via Component::setViewportIgnoreDragFlag()? This will ensure that mouse events on the Component will be ignored when it is inside a Viewport with drag-to-scroll functionality enabled.
Good to hear. Our reason for not setting it as the default behaviour is for backwards compatibility as it would silently change the behaviour of viewport components for a lot of people who rely on the current behaviour.
Just to note that the problem I’m having now, is that if I’m dragging by (say) a Button; when I stop dragging and release the button, that button is activated!
No, setting the ignoreDrag flag will just ensure that Components don’t receive mouse events when you are dragging the Viewport, it won’t handle cancelling mouse downs for you. Perhaps you could set a flag in the parent component of the Viewport when it is dragged and check it in the button’s callback?
Thanks for that. Confirms what I expected! I’d already started going down this route, but it didn’t work well - however, I think that in combination with viewportIgnoreDragFlag it should be easy enough to get working again.
Suggestion to devs: when dragging of the list port stops, delay the update of state for a short while; that would prevent issues like this happening at all, and would remove the need for quite a bit of custom code in apps like mine…