Knob position vs. slider value
pointForValue() function you can get a readout of what would be the knob’s position for a particular value.
valueForPoint() works the other way round: you give it a (hypothetical) position of the knob, and it will return the value this would generate.
These functions don’t change anything to the slider itself; they just return the numbers the slider uses internally.
We have a default slider:
slider = new SliderComponent
With its default
min value of
0, and default
1, the position for value
0.5 will be at
# What would be the location of the knob # for a value of 0.5? print slider.pointForValue 0.5 » 150
This, of course, is what would be the
x position of the knob inside its parent (the slider itself) and not the position of the knob on the screen. (For a vertical slider you will get a
valueForPoint() function does exactly the reverse.
# What would be the slider’s value with # the knob halfway (at 150 points)? print slider.valueForPoint 150 » 0.5