The NSScrollView and NSTextView Classes
In Chapter 10 we introduced the NSScrollView and NSTextView classes when we dragged an NSScrollView object from IB’s Cocoa-Data palette into a MathPaper window. At the time, we said that the NSScrollView object “contains” an NSTextView object. Perhaps a better way of putting it is to say that an NSTextView is “embedded” inside each NSScrollView. The NSScrollView object in IB’s Palettes window actually contains the following nine objects:
- NSScrollView
Displays the scroller and does the actual scrolling
- NSTextView
Displays the text
- NSClipView
Helps arrange the communication between the NSScrollView and the NSTextView
- Vertical scroller
Controls up-down scrolling and shows where you are in the document
- Horizontal scroller
Controls left-right scrolling and shows where you are in the document
- NSTextStorage object
Holds the data that the NSTextView displays
- NSTextContainer object
Defines the region where the text will be displayed
- NSLayoutManager object
Controls the layout of the NSTextStorage object’s information within the NSTextView
- NSSimpleHorizontalTypesetter
Does the typesetting
You can control whether each scroller is displayed by sending the setHasVerticalScroller: or setHasHorizontalScroller: messages (with the arguments YES or NO) to the NSScrollView. By default, the NSScrollView that you drag off IB’s Cocoa-Data palette displays the vertical scroller, but not the horizontal one.
NSTextView objects are most frequently used with NSScrollView ...
Get Building Cocoa Applications: A Step by Step Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.