Bug report: Missing update of slider text box


#1

Hi Jules

First post here. I have been tracking Juce from the sideline for quite some time and I like what I see. We are considering using your framework for a major project (and will of course buy a license for that), but as always I like to check things out on smaller pilot projects first. Which is what I am doing right now :slight_smile:

I believe I found a bug in the Slider code:
The associated texbox does not update unless the slider value is actually changed. If, for instance, the slider is at one end (say max value 10.0) and an out-of-limit value (say 100) is typed into the textbox the text stays at what was entered.

The cause is quite easily spotted in Slider::setValue where the criterion for calling updateText() & repaint() is simply (currentValue != newValue).
The easy way to go would be to always update the text in response to a change. This would also take care of cleaning up the text after user entry and displaying the actual rounded slider value (after clipping to ‘interval’).
I don’t think there would be any performance penalty from this fix, but I may be wrong since I am not that familiar with the framework yet.

Best regards and thanks for your excellent work,
Niels Farver


#2

Hi, and welcome… Interesting point, though I’d be a bit worried about making it update the text every time - how about this instead (just an idea, I’ve not actually tried it yet):

[code]void Slider::labelTextChanged (Label* label)
{
const double newValue = snapValue (getValueFromText (label->getText()), false);

if (getValue() != newValue)
{
    sendDragStart();
    setValue (newValue, true, true);
    sendDragEnd();
}
else
{
    updateText();
}

}[/code]


#3

Hmmm…
Will not do the trick (I actually checked it).
It would work if snapValue() also limited and rounded the value, and then
even that would not be enough, since extra characters such as leading +'s would not get cleaned up.

I checked that an unconditional call to updateText() actually works.

So a working fix would be:

[code]void Slider::labelTextChanged (Label* label)
{
const double newValue = snapValue (getValueFromText (label->getText()), false);

if (getValue() != newValue)
{
    sendDragStart();
    setValue (newValue, true, true);
    sendDragEnd();
}
updateText();

}
[/code]


#4

Ah, good point. Thanks, I’ll make that change.


#5