I’d like to add some text above or below where the slider marker currently is sitting. I guess I could brute force it somehow using map(), getValueS and some trial and error offsets but since the slider already knows where it’s at in the frame, to show values via setShowValue(), I was hoping I could somehow get those coordinates so I could put my own text there instead.(Sorry about the run on sentence. Sadly that’s how I code too. Sigh…
You can already do this with
slider1.setShowValue(true); // thumb value slider1.setShowLimits(true); // min/ max values
Thanks. From the docs it wasn’t clear to me how to set the value or how to offset it. What I’m wanting to do is as the handle is set I want to show the date, eg. 5/1/2020 in an area below the slider. So was hoping somehow to get the x value in the frame where the handle is currently positioned. Probably simple but I couldn’t figure it out.
Sorry that option is not available in G4P
Well that makes me feel (somewhat) better. Just thought I was missing something. Maybe I can brute force something using getvalue() and use that with an offset constant to reasonably approximate the actual x value in the frame. Thanks for a your great contributions!
Its easy, assume the slider is called
s then the horizontal position of the thumb centre is given by
float x = map(s.getValueF(), s.getStartValue(), s.getEndValue(), s.getX(), s.getX() + s.getWidth());
map()! Of course! Thanks!
Hmmm… It didn’t resolve the getStartValue() and getEndValue() methods. Tried getStartValueI() and getEndValueI() and also no joy. Also I didn’t find them in the reference. Sorry I’m pretty dense about these things.
getEndLimit, my mistake LOL
That did it thanks. Perfect!