A slider is a control that displays a range of values and has an indicator, or knob, which indicates the current setting. Optionally, it can have tick marks at regularly spaced intervals. A slider can be a bar or a dial. The user moves the knob along the slider’s bar, or around the dial, to change the setting.
A slider’s behavior and appearance is controlled by the class
NSSliderCell object must be contained within a subclass of NSControl. If you need one slider, use an
NSSlider object that contains a single
NSSliderCell object. If you need a group of related sliders, use an
NSMatrix object that contains several
NSSliderCell objects. Most
NSSliderCell methods have covers in
NSSlider, which simply call the
NSSliderCell equivalent. For more information, see the
NSSlider class specifications.
Setting a Slider’s Values
To set the slider’s minimum and maximum values, use
setMaxValue:. To read the slider’s value, as represented by the knob’s current position, use an
NSControl “get” method, such as
floatValue;. To set the slider’s value, use an
NSControl “set” method, such as
Displaying a Slider’s Name and Values
You should use text fields to display the slider’s name, minimum value, maximum value, and tick-mark value. Although you can set a title for a slider that’s displayed automatically, it’s displayed right in the slider’s bar and is easily obscured by the knob. There is no way for a slider to display automatically its minimum, maximum, and tick-mark values.