NSAcceleratorButton
A button that sends an action when the user first clicks the button and continues sending actions until the user releases pressure entirely.
Declaration
static const NSButtonType NSAcceleratorButton;Discussion
On pressure-sensitive systems, such as systems with the Force Touch trackpad, an accelerator button sends repeating actions as pressure changes occur. It stops sending actions when the user releases pressure entirely. A media player app, for example, might implement an accelerator button in order to allow a user to adjust the speed of fast forward or rewind with variable pressure. In this case, the button sends actions to the app to indicate when the user changes pressure on the button. The app then determines the amount of pressure the user is currently applying and adjusts playback speed accordingly.
For continuous accelerator buttons (see isContinuous), the interval between repeating actions (a rate typically specified with setPeriodicDelay(_:interval:)) automatically adjusts to match the applied pressure. As the user force clicks (presses harder), the button sends actions more rapidly. As the user reduces pressure on the button, actions slow down. As such, the user has direct control over how fast the button sends actions. Continuous accelerator buttons are intended for continuously advancing through a series of discrete objects, such as photos in an album or pages in a book.
For noncontinuous accelerator buttons, they send actions whenever a change in force occurs. Noncontinuous accelerator buttons are for adjusting the speed of navigation, such as playback speed in a media player, based on pressure. After the user releases the button, the button sends a final action.
For buttons that aren’t accelerator buttons, the value of the button matches its state. For accelerator buttons, the value of the button is distinct from its state and indicates pressure level. While the user force clicks the button, doubleValue is a measurement of pressure between 1.0 and approaching 2.0. When the user releases the button, doubleValue is 0.0.
An accelerator button appears like any other button and doesn’t provide any visual indication that it supports variable pressure. To provide this type of visual indication, you can apply a custom image to the button.
On a system that doesn’t support pressure sensitivity, an accelerator button behaves like a button of type NSMomentaryLightButton.