How to ignore mouse move from slider

Hi all, I have a screen with a viewport, inside it, I have a Slider, when a page is too long, I need to scroll the vertical scrollbar, but when the mouse meets the slider, it just moves the slider’s value and doesn’t move the page. So, how can I solve this problem?

There is a method slider.setScrollWheelEnabled (false), that should do the trick.
If all else fails, overriding the Slider::mouseWheelMove(//) is also an option.

Hope this helps…


void Component::setViewportIgnoreDragFlag ( bool ignoreDrag ) noexcept

Sets a flag to indicate whether mouse drag events on this Component should be ignored when it is inside a Viewport with drag-to-scroll functionality enabled.

This is useful for Components such as sliders that should not move their parent Viewport when dragged.

You can actually call this on any component, not only sliders.

That’s interesting, didn’t know that one. Thanks @Achder. So there are more options :slight_smile:

@Achder, I done m_slider.setViewportIgnoreDragFlag(flase); but it’s not effect.
I tried @daniel solution, slider.setScrollWheelEnabled (false), it worked.

You have to set the flag to true, not to false.

Yes @Achder I set the flag to true

@Achder, @daniel, I have an idea: Can I detect that scrollbar is scrolling, so that the slider will changes (or effect) the value, if scrollbar of the viewport isn’t scrolling, the value will be changed if the mouse position is in the slider and wheeling?