Home

NSControl

NSControl is an abstract base class in the AppKit framework of macOS that provides common behavior for interactive controls. It is a subclass of NSView and serves as the parent for widgets such as buttons, text fields, sliders, pop-up menus, and other controls that display a value and support editing or interaction. The primary responsibilities of NSControl are to manage the control's displayed value and to route user input to the application's data model via the target–action mechanism.

A central feature is the target and action pair. Each NSControl can have a target object and

NSControl exposes a range of value-related properties, such as stringValue, intValue, floatValue, doubleValue, and objectValue, as

In terms of architecture, NSControl historically relies on NSCell for drawing and event handling, though modern,

NSControl also integrates with macOS accessibility and supports various presentation details such as enabled state, focus

an
action
selector.
When
the
user
changes
the
control’s
value,
the
control
sends
the
action
message
to
its
target,
typically
including
the
control
as
the
sender.
Many
controls
can
be
configured
to
send
updates
continuously
as
the
user
drags
or
types.
well
as
generic
get/set
methods.
It
also
supports
Cocoa
Bindings,
allowing
a
control’s
value
and
other
properties
to
be
bound
to
model
objects
or
controllers.
view-based
controls
in
AppKit
still
inherit
the
same
NSControl
interface.
Subclasses
include
NSButton,
NSTextField,
NSSlider,
NSStepper,
NSPopUpButton,
NSComboBox,
NSSegmentedControl,
NSColorWell,
and
NSDatePicker,
among
others.
ring,
and
highlighting,
depending
on
the
concrete
subclass.