ListBox, ViewPort and control activation while the ViewPort is moving due to drag

Hi all,

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.

Thanks in advance for any suggestions.

Pete

Raised as issue at https://github.com/WeAreROLI/JUCE/issues/364

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.

Hi Ed,

Wow - you are a star. That fixed the problem - great news!

Note to devs: I have a feeling that this really should be the default behaviour.

Thanks again!

Pete

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.

Hi Ed,

Makes sense. Of course, it might make sense to have a global default behaviour, which could be toggled easily enough for all components by one call.

Best wishes,

Pete

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!

Is there a work-around for that?

Pete

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?

Hi Ed,

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…

Pete