Instance Method

scrollRect:by:

Copies the visible portion of the view’s rendered image within a region and lays that portion down again at a specified offset .

Declaration

- (void)scrollRect:(NSRect)rect by:(NSSize)delta;

Parameters

aRect

A rectangle defining a region of the view.

offset

A NSSize structure that specifies an offset from from aRect’s origin.

Discussion

This method is useful during scrolling or translation of the coordinate system to efficiently move as much of the view’s rendered image as possible without requiring it to be redrawn, following these steps:

  1. Invoke scrollRect:by: to copy the rendered image.

  2. Move the view object’s origin or scroll it within its superview.

  3. Calculate the newly exposed rectangles and either set the needsDisplay property to YES or call setNeedsDisplayInRect: to draw them.

You should rarely need to use this method, however. The scrollPoint:, scrollRectToVisible:, and autoscroll: methods automatically perform optimized scrolling.

See Also

Scrolling

- prepareContentInRect:

Prepares the overdraw region for drawing.

preparedContentRect

The portion of the view that has been rendered and is available for responsive scrolling.

- scrollPoint:

Scrolls the view’s closest ancestor NSClipView object so a point in the view lies at the origin of the clip view's bounds rectangle.

- scrollRectToVisible:

Scrolls the view’s closest ancestor NSClipView object the minimum distance needed so a specified region of the view becomes visible in the clip view.

- autoscroll:

Scrolls the view’s closest ancestor NSClipView object proportionally to the distance of an event that occurs outside of it.

- adjustScroll:

Overridden by subclasses to modify a given rectangle, returning the altered rectangle.

enclosingScrollView

The nearest ancestor scroll view that contains the current view.

- scrollClipView:toPoint:

Notifies the superview of a clip view that the clip view needs to reset the origin of its bounds rectangle.

- reflectScrolledClipView:

Notifies a clip view’s superview that either the clip view’s bounds rectangle or the document view’s frame rectangle has changed, and that any indicators of the scroll position need to be adjusted.