A view that draws text and handles user interactions with that text.
SDK
- macOS 10.0+
Framework
- App
Kit
Declaration
class NSTextView : NSText
Overview
The NSText
class is the front-end class to the AppKit text system. The class draws the text managed by the back-end components and handles user events to select and modify its text, in addition to supporting rich text, attachments, input management and key binding, and marked text attributes.
Note
If you need only to implement a simple editable text field, see NSText
.
NSText
is the principal means to obtain a text object that caters to almost all needs for displaying and managing text at the user interface level. While NSText
is a subclass of the NSText
class—which declares the most general Cocoa interface to the text system—NSText
adds major features beyond the capabilities of NSText
. You can also do more powerful and more creative text manipulation (such as displaying text in a circle) using NSText
, NSLayout
, NSText
, and related classes.
You are more likely to use the NSText
class than the NSText
class. It is also important to remember that NSText
conforms to a large number of protocols, the methods of which are available to instances of the NSText
class.
NSText
communicates with its delegate through methods declared both by the NSText
and by its superclass’s protocol, NSText
. All delegation messages come from the first text view. To fully understand how to use this class, read Cocoa Text Architecture Guide and Text System User Interface Layer Programming Guide.
About Delegate Methods
The NSText
class communicates with its delegate through methods declared both by the NSText
and by its superclass’s protocol, NSText
. All delegation messages come from the first text view.