Small bug with Mouse Wheel on Linear Bar Sliders


Hi Jules !

There’s an unwanted behaviour in the Slider class when dealing with mouse wheel events over a Linear Bar slider.

For each mouse wheel move, the Linear Bar slider get two consecutive events… making it impossible to have fine value changes… !

Here is the point:

The Linear Bar slider registers as a MouseListener on its value box (In juce_Slider.cpp, line 346).

When the mouse wheel move, the value box component receives the internal mouse wheel callback and:

  • first call its own mouseWheelMove() (inherited from Component) whose default behaviour (in juce_Component.cpp, line 2130) is to pass the event up to the parent (the slider)
  • and then call mouseWheelMove() on all its MouseListeners (including the slider)

This results in having the Slider::mouseWheelMove called twice …

I find a bit strange to have a Component::mouseWheelMove() default behavior whereas all the other MouseListener methods are empty in Component…
AFAIK, this default behavior is made for scrollbars… but unfortunately induces weird behaviours for some other components…

I haven’t find any solution not preventing either the Sliders or the Scrollbars to work so far.

Any idea ?

PS: I’ve not tried the last tip, i’m using r707 but haven’t seen any related SVN changes since then.


Hmm - that does look like a little buggette. How about this:

void Slider::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) { if (scrollWheelEnabled && isEnabled() && style != TwoValueHorizontal && style != TwoValueVertical && e.originalComponent != valueBox) {



Nope. It’s not the solution !

This completely disables the mouse wheel on Linear Bars, as e.originalComponent is always the valueBox …


oh yes, of course… Ok, looks like it’ll be a bit more work then. I think this might do the trick, in juce_LookAndFeel.cpp:

[code]class SliderLabelComp : public Label
SliderLabelComp() : Label (String::empty, String::empty) {}
~SliderLabelComp() {}

void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) {}


Label* LookAndFeel::createSliderTextBox (Slider& slider)
Label* const l = new SliderLabelComp();



Yes, it works.

I did think to that solution but found it certainly wasn’t the right one as the problem comes from a default impl that should not exist… (Component::mouseWheelMove()).

Anyway, it does the trick in my case!

Thanks a lot!