Text box for two value slider


#1

It’s a very good feature to have a text entry box for slider. But this box does not work with two valued slider. I found you only need to override two functions to make it work:

void Slider::labelTextChanged(Label* label)
{
	const String text = label->getText();
	int index = text.indexOfChar(T(','));
	if(index>0)
	{
		const String low = text.substring(0, index);
		const String high = text.substring(index+1, text.length());
		setMinValue(low.getDoubleValue());
		setMaxValue(high.getDoubleValue());
		updateText();
	}
}

const String getTextFromValue(double value)
{
	String text;
	text.printf(T("%.0f,%.0f"), getMinValue(), getMaxValue());
	return text;
}

However, the labelTextChanged in Slider is not virtual so I cannot override it. Is it possible to add this small feature? Thanks.


#2

?? It’s already virtual - it’s part of the LabelListener interface…


#3

But the Slider class override it with a non-virtual one. Does this work in C++?


#4

It’s impossible to ‘unvirtualise’ a method! Any method that overrides a virtual method is by definition virtual, you don’t need to use the keyword.