An NSClip holds the document view of an NSScroll, clipping the document view to its frame, handling the details of scrolling in an efficient manner, and updating the NSScroll when the document view’s size or position changes. You don’t normally use the NSClip class directly; it’s provided primarily as the scrolling machinery for the NSScroll class. However, you might use the NSClip class to implement a class similar to NSScroll.
Language
- Swift
- Objective-C
SDK
- macOS 10.0+
Overview
Interaction with NSScrollView
When using an NSClip within an NSScroll (the usual configuration), you should access the NSScroll properties that control background drawing state, rather than accessing these properties of the NSClip. This recommendation applies to the following properties:
The NSClip methods are intended for when the NSClip is used independently of a containing NSScroll. In the usual case, NSScroll should be allowed to manage the background-drawing properties of its associated NSClip.
There is only one background-drawing state per NSScroll/NSClip pair. The two objects do not maintain independent and distinct draws and background properties; rather, the accessors for these properties on NSScroll largely defer to the associated NSClip and allow the NSClip to maintain the state. Note that this state is not cached by the NSScroll object.
It is also important to note that setting draws to false in an NSScroll has the added effect of setting the NSClip property copies to false. The side effect of setting the draws property directly to the NSClip is the appearance of “trails” (vestiges of previous drawing) in the document view as it is scrolled.