Contents

NSControl.Events

A set of events that a control can report to its target.

Declaration

struct Events

Discussion

You set up a control to send an action message to a target object by associating both target and action with one or more control events. To do this, call addTarget(_:action:for:) on the control for each target-action pair you want to specify.

let slider = NSSlider()
slider.addTarget(self, action: #selector(sliderValueChanged), for: .valueChanged)

let button = NSButton()
button.addTarget(self, action: #selector(buttonActivated), for: [.primaryActionTriggered, .menuActionTriggered])

Use tracking events to observe the progress of mouse interaction as it unfolds — for example, to respond to a drag in progress rather than only on completion. Use semantic events like valueChanged, primaryActionTriggered, or menuActionTriggered to respond to higher-level, input-device-independent meanings. applicationReserved is a range of bits available for app use.

Topics

Tracking events

Semantic events

Aggregate events

Reserved ranges

Initializers

See Also

Handling Control Events