How to add a slider, but without the slider bit?


#1

Let’s suppose that you have added a slider to a GUI with an edit box, but one day you realise that the slider part has outgrown its usefulness.

How might one go about removing it? There appears to be no slider->disableSliderBit(true).

Or can Labels or Text Editor boxes be configured to only accept (int/float) numbers with specific min/max/interval, like the edit box of a slider?

I’m asking for a friend…


#2

In my opinion the slider needs a true text-only mode, but there are some tricks to get something like you requested


#3

If I understand,
To remove you can :
Slider->setVisible(false);

For the only float number you can:

float stringToFloat (String& str)
{
    if(str.containsOnly("0123456789.-"))
    {
        return str.getFloatValue();
    }
    else
    {
        return 0.0f;
    }
}

#4

Thanks! I’ll (or rather my friend will…) give it a go.