Mac Developer Library

Developer

AppKit Framework Reference NSClipView Class Objective-C Reference

Options
Deployment Target:

On This Page
Language:

NSClipView

Class at a Glance

An NSClipView contains and scrolls the document view displayed by an NSScrollView. You normally don’t need to program with NSClipViews, as NSScrollView handles most of the details of their operation.

More...

Inheritance


Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.0 and later.
  • Sets the receiver’s document view to aView, removing any previous document view, and sets the origin of the receiver’s bounds rectangle to the origin of aView’s frame rectangle.

    Declaration

    Swift

    unowned(unsafe) var documentView: AnyObject?

    Objective-C

    @property(assign) id documentView

    Discussion

    If the receiver is contained in an NSScrollView, you should send the NSScrollView a setDocumentView: message instead, so it can perform whatever updating it needs.

    In the process of setting the document view, this method registers the receiver for the notifications NSViewFrameDidChangeNotification and NSViewBoundsDidChangeNotification, adjusts the key view loop to include the new document view, and updates a parent NSScrollView’s display if needed using reflectScrolledClipView:.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s document view.

    Declaration

    Swift

    unowned(unsafe) var documentView: AnyObject?

    Objective-C

    @property(assign) id documentView

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Changes the origin of the receiver’s bounds rectangle to newOrigin.

    Declaration

    Swift

    func scrollToPoint(_ newOrigin: NSPoint)

    Objective-C

    - (void)scrollToPoint:(NSPoint)newOrigin

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Scrolls the receiver proportionally to theEvent’s distance outside of it.

    Declaration

    Swift

    func autoscroll(_ theEvent: NSEvent) -> Bool

    Objective-C

    - (BOOL)autoscroll:(NSEvent *)theEvent

    Discussion

    theEvent’s location should be expressed in the window’s base coordinate system (which it normally is), not the receiving NSClipView’s. Returns YEStrue if any scrolling is performed; otherwise returns NOfalse.

    Never invoke this method directly; instead, the NSClipView’s document view should repeatedly send itself autoscroll: messages when the cursor is dragged outside the NSClipView’s frame during a modal event loop initiated by a mouse-down event. The NSView class implements autoscroll: to forward the message to the receiver’s superview; thus the message is ultimately forwarded to the NSClipView.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a scroll point adjusted from proposedNewOrigin, if necessary, to guarantee the receiver will still lie within its document view.

    Declaration

    Swift

    func constrainScrollPoint(_ newOrigin: NSPoint) -> NSPoint

    Objective-C

    - (NSPoint)constrainScrollPoint:(NSPoint)newOrigin

    Discussion

    For example, if proposedNewOrigin’s y coordinate lies to the left of the document view’s origin, then the y coordinate returned is set to that of the document view’s origin.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.10.

  • Controls whether the receiver copies rendered images while scrolling.

    Declaration

    Swift

    var copiesOnScroll: Bool

    Objective-C

    @property BOOL copiesOnScroll

    Discussion

    If flag is YEStrue, the receiver copies the existing rendered image to its new location while scrolling and only draws exposed portions of its document view. If flag is NOfalse, the receiver always forces its document view to draw itself on scrolling.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns YEStrue if the receiver copies its existing rendered image while scrolling (only drawing exposed portions of its document view), NOfalse if it forces its contents to be redrawn each time.

    Declaration

    Swift

    var copiesOnScroll: Bool

    Objective-C

    @property BOOL copiesOnScroll

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the rectangle defining the document view’s frame, adjusted to the size of the receiver if the document view is smaller.

    Declaration

    Swift

    var documentRect: NSRect { get }

    Objective-C

    @property(readonly) NSRect documentRect

    Discussion

    In other words, this rectangle is always at least as large as the receiver itself.

    The document rectangle is used in conjunction with an NSClipView’s bounds rectangle to determine values for the indicators of relative position and size between the NSClipView and its document view. For example, NSScrollView uses these rectangles to set the size and position of the knobs in its scrollers. When the document view is much larger than the NSClipView, the knob is small; when the document view is near the same size, the knob is large; and when the document view is the same size or smaller, there is no knob.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the exposed rectangle of the receiver’s document view, in the document view’s own coordinate system.

    Declaration

    Swift

    var documentVisibleRect: NSRect { get }

    Objective-C

    @property(readonly) NSRect documentVisibleRect

    Discussion

    Note that this rectangle doesn’t reflect the effects of any clipping that may occur above the NSClipView itself. To get the portion of the document view that’s guaranteed to be visible, send it a visibleRect message.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the cursor object used over the receiver to aCursor.

    Declaration

    Swift

    var documentCursor: NSCursor?

    Objective-C

    @property(strong) NSCursor *documentCursor

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the cursor object used when the cursor lies over the receiver.

    Declaration

    Swift

    var documentCursor: NSCursor?

    Objective-C

    @property(strong) NSCursor *documentCursor

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns YEStrue if the receiver draws its background color.

    Declaration

    Swift

    var drawsBackground: Bool

    Objective-C

    @property BOOL drawsBackground

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets whether the receiver draws its background color, depending on the Boolean value flag.

    Declaration

    Swift

    var drawsBackground: Bool

    Objective-C

    @property BOOL drawsBackground

    Discussion

    If your NSClipView is enclosed in an NSScrollView, you should send the setDrawsBackground: message to the NSScrollView. Sending a setDrawsBackground: message with a parameter of NO to an NSScrollView has the added effect of sending the NSClipView a setCopiesOnScroll: message with a parameter of NO. The side effect of sending the setDrawsBackground: message directly to the NSClipView is the appearance of “trails” (vestiges of previous drawing) in the document view as it is scrolled.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the receiver’s background color to aColor.

    Declaration

    Swift

    @NSCopying var backgroundColor: NSColor

    Objective-C

    @property(copy) NSColor *backgroundColor

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the color of the receiver’s background.

    Declaration

    Swift

    @NSCopying var backgroundColor: NSColor

    Objective-C

    @property(copy) NSColor *backgroundColor

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.