Change to something like that:
1 Like
Look at the reference and source under Slider and TickMark – a Slider lets you get its number of ticks, and retrieve each TickMark object by index; a TickMark lets you add a label.
- http://www.sojamo.com/libraries/controlP5/reference/controlP5/Slider.html#getTickMark-int-
- http://www.sojamo.com/libraries/controlP5/reference/controlP5/TickMark.html#setLabel-java.lang.String-
So to autolabel you can retrieve your slider, loop over its ticks, and label each one – for example, with their index value:
void tickLabeler(Slider sl){
for(int i=0; i<sl.getNumberOfTickMarks(); i++){
TickMark t = sl.getTickMark(i);
t.setLabel(str(i));
}
}
You can use that function like this:
Slider s = cp5.get(Slider.class, "mySlider");
tickLabeler(s);
Or, in your example, just do it manually:
Slider s = cp5.get(Slider.class, "mySlider");
s.getTickMark(0).setLabel("Slow");
s.getTickMark(1).setLabel("Medium");
s.getTickMark(2).setLabel("Fast");
1 Like
Thanks