The most visible aspects of an application are
controls that users interact with. In Cocoa, control objects such as
buttons, tables, sliders, and text fields all have a common parent
, which is itself a subclass of
NSView. Figures Figure 3-6 and
3-7 show the class hierarchies for
NSControl, and Table 3-1
describes the control classes implemented in the Application Kit.
In general, a Cocoa control must have the ability to do several things:
Draw itself on the screen.
Respond to basic events such as a mouseclick or a drag.
Send action messages to arbitrary objects in response to events.
NSControl gives some amount of control over when
and how a control sends the action message to its target.
Specifically, you can specify whether the action is to be sent only
after the user has finished clicking the control (i.e., when the
mouse button is raised), or if the action is to be sent continuously
while the mouse button is depressed. You can set this behavior either
in Interface Builder or by using the method
controls have associated cell classes, and in those cases the cell
implements all drawing and event handling, while the control serves
as a container within which the cell is drawn. A cursory comparison
NSControl makes it appear as though these classes unnecessarily ...