Slider - Mouse Wheel Erroneous Behaviour?

Playing around with the Slider, noticed that it produces erroneous behaviour when the range value is greater then or equal to 2560... is that me, or is that a bug?

If the maximum value is less then or equal to 2559, mouse wheel change increments/decrements by 1 as expected.

Once the value is greater then or equal to 2560, mouse wheel change increments/decrements by 2...

Juce v4.1.0, code:


    zSlider = new Slider();
    zSlider->setBounds(20, 20, 50, 100);
    zSlider->setSliderStyle(juce::Slider::SliderStyle::LinearBarVertical);
    zSlider->setRange(0.0, 2560.0, 1.0);
    zSlider->addListener(this);
    addAndMakeVisible(zSlider);
​

Presumably it depends on the sensitivity of your mouse wheel. At some point the slider interval is so tiny compared to its range that the resolution is not enough to resolve the individual steps. With my Apple magic mouse and your code, the mouse wheel increment can be 1, 2, or 3, depending on how gently I am touching the mouse. With another mouse, you can get different results.

This is easily fixed by simply increasing the size of your slider.

I wouldn't consider it a bug. The slider-step-per-mouse-wheel-step resolution needs to be relative like this, otherwise you would need to keep scrolling forever if your slider happens to have a lot of possible values.

Of course. Makes sense, appreciate the sanity check. I'm too used to grabbing the delta in WinForms.

The reason I asked was because the behaviour changes for me at 2560, regardless of if the slider is 100px, or 1,000px high.

I do actually have a requirement for such fine changes, so I'll figure out how to override that behaviour when using a modifier key, that will increment/decrement by 1 regardless.

 

Can anyone else replicate this behaviour?

false: max value on slider2, slider3, slider5 is 2559, then increments are by one.
true: max value on slider2, slider3, slider5 is 2660, then increments are by two.

If this is intentional behaviour, then how do you adjust the slider by one?

setSize (2400, 800);

bool showBug = true;
int juceBug = 0;
if(showBug) { juceBug = 2560; }
else { juceBug = 2559; }

slider1 = new Slider("slider1");
addAndMakeVisible(slider1);
slider1->setBounds(20, 20, 40, 100);
slider1->setSliderStyle(juce::Slider::SliderStyle::LinearVertical);
slider1->setTextBoxStyle(juce::Slider::TextBoxBelow, true, 60, 20);
slider1->setRange(0, 10, 1);

slider2 = new Slider("slider2");
addAndMakeVisible(slider2);
slider2->setBounds(60, 20, 40, 700);
slider2->setSliderStyle(juce::Slider::SliderStyle::LinearVertical);
slider2->setTextBoxStyle(juce::Slider::TextBoxBelow, true, 60, 20);
slider2->setRange(0, juceBug, 1);

slider3 = new Slider("slider3");
addAndMakeVisible(slider3);
slider3->setBounds(20, 200, 40, 100);
slider3->setSliderStyle(juce::Slider::SliderStyle::Rotary);
slider3->setTextBoxStyle(juce::Slider::TextBoxBelow, true, 60, 20);
slider3->setRange(0, 10, 1);

slider4 = new Slider("slider4");
addAndMakeVisible(slider4);
slider4->setBounds(20, 300, 40, 100);
slider4->setSliderStyle(juce::Slider::SliderStyle::Rotary);
slider4->setTextBoxStyle(juce::Slider::TextBoxBelow, true, 60, 20);
slider4->setRange(0, juceBug, 1);

slider5 = new Slider("slider5");
addAndMakeVisible(slider5);
slider5->setBounds(10, 750, 2300, 40);
slider5->setSliderStyle(juce::Slider::SliderStyle::LinearHorizontal);
slider5->setTextBoxStyle(juce::Slider::TextBoxBelow, true, 60, 20);
slider5->setRange(0, juceBug, 1);

Couldn’t it be, that this is intentional behaviour? If you want to scroll through a large range, you will end up with a bleeding finger…
Anyways, you find the code here:

I would say, the 0.15f in line 988 is a value arbitrarily chosen, but I might be wrong.
I would rather ask myself, do I really want to scroll a range of over 2600 with the mouse wheel with that accuracy?

As above, no, it doesn’t. Can you replicate that or not?

[quote=“daniel, post:5, topic:16479”]
Couldn’t it be, that this is intentional behaviour? If you want to scroll through a large range, you will end up with a bleeding finger…Anyways, you find the code here:[/quote]

I don’t like end users :slight_smile:

Thanks for the answer / code, much appreciated.

Neither do I, the point is that I have that scenario, and the answer, along with the Slider class is not satisfactory.

So I guess I’ll just have to work around it…