Class

NSSlider

A slider is a UI element that displays a range of values in the app. Sliders can be vertical or horizontal bars or circular dials. An indicator, or knob, notes the current setting. The user can move the knob in the slider’s bar—or rotate the knob in a circular slider—to change the setting.

Overview

The NSSlider class uses the NSSlider​Cell class to implement its user interface.

Symbols

Creating Sliders

init(target:​ Any?, action:​ Selector?)

Creates and returns a continuous horizontal slider whose values range from 0.0 to 1.0.

init(value:​ Double, min​Value:​ Double, max​Value:​ Double, target:​ Any?, action:​ Selector?)

Creates and returns a continuous horizontal slider that represents values over the specified range.

Managing the Slider’s Appearance

var slider​Type:​ NSSlider​Type

The type of the slider, such as vertical or circular.

var alt​Increment​Value:​ Double

The amount by which the receiver changes its value when the user Option-drags the slider knob.

var knob​Thickness:​ CGFloat

The knob’s thickness, in pixels.

var is​Vertical:​ Bool

An integer indicating the orientation (horizontal or vertical) of the slider.

Asking About the Value Limits

var max​Value:​ Double

The maximum value the receiver can send to its target.

var min​Value:​ Double

The minimum value the receiver can send to its target.

Handling Mouse-Down Events

func accepts​First​Mouse(for:​ NSEvent?)

Returns a Boolean value indicating whether the slider accepts a single mouse-down event that simultaneously activates the window and takes hold of the slider’s knob.

Managing Tick Marks

var allows​Tick​Mark​Values​Only:​ Bool

A Boolean value that indicates whether the receiver fixes its values to those values represented by its tick marks.

func closest​Tick​Mark​Value(to​Value:​ Double)

Returns the value of the tick mark closest to the specified value.

func index​Of​Tick​Mark(at:​ NSPoint)

Returns the index of the tick mark closest to the location of the receiver represented by the given point.

var number​Of​Tick​Marks:​ Int

The number of tick marks associated with the receiver.

func rect​Of​Tick​Mark(at:​ Int)

Returns the bounding rectangle of the tick mark at the given index.

var tick​Mark​Position:​ NSTick​Mark​Position

Determines how the receiver’s tick marks are aligned with it.

func tick​Mark​Value(at:​ Int)

Returns the receiver’s value represented by the tick mark at the specified index.

Instance Properties

var track​Fill​Color:​ NSColor?

The color of the filled portion of the slider track, in appearances that support it.