How to ignore mouse move from slider


#1

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?


#2

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…


#3

setViewportIgnoreDragFlag()

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.


#4

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


#5

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


#6

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


#7

Yes @Achder I set the flag to true


#8

@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?