Class

NSScroller

An object that controls scrolling of a document view within a scroll view or other type of container view.

Declaration

@interface NSScroller : NSControl

Overview

A scroller displays a slot containing a knob that the user can drag directly to the desired location. The knob indicates both the position within the document view and—by varying in size within the slot—the amount visible relative to the size of the document view.

Typically, you don’t need to program with scrollers; instead, you configure them with an NSScrollView object in a Nib file.

Don’t use an scroller when a slider would be more appropriate. An NSSlider object represents a range of values for something in the application and lets the user choose a setting. A scroller represents the relative position of the visible portion of a view and lets the user choose which portion to view.

Topics

Determining Scroller Size

+ scrollerWidthForControlSize:scrollerStyle:

Returns the width for scrollers of the receiving class for a given control size and scroller style.

+ scrollerWidth

Returns the width for scrollers of the receiving class, assuming a control size NSRegularControlSize, and a scroller style of NSScrollerStyleLegacy.

Deprecated
+ scrollerWidthForControlSize:

Returns the width of the scroller based on controlSize and assuming a scroller style of NSScrollerStyleLegacy.

Deprecated
controlSize

The size of the scroller.

Laying out a Scroller

arrowsPosition

The location of the scroll buttons within the scroller, as described in NSScrollArrowPosition.

Deprecated

Setting the Knob Position

- setFloatValue:knobProportion:

Sets the position of the knob to aFloat, which is a value from 0.0 (indicating the top or left end) to 1.0 (the bottom or right end).

Deprecated
- setKnobProportion:

The proportion of the knob slot that the knob should fill.

Calculating Layout

- rectForPart:

Returns the rectangle occupied by aPart, which for this method is interpreted literally rather than as an indicator of scrolling direction.

- testPart:

Returns the part that would be hit by a mouse-down event at aPoint (expressed in the window’s coordinate system).

- checkSpaceForParts

Checks to see if there is enough room in the receiver to display the knob and buttons.

usableParts

A value that indicates which parts of the receiver are displayed and usable.

Drawing Scroller Parts

- drawArrow:highlight:

Draws the scroll button indicated by arrow, which is either NSScrollerIncrementArrow (the down or right scroll button) or NSScrollerDecrementArrow (up or left).

Deprecated
- drawKnobSlotInRect:highlight:

Draws the portion of the scroller’s track, possibly including the line increment and decrement arrow buttons, that falls in the given rectangle.

- drawKnob

Draws the knob.

- drawParts

Caches images for the scroll buttons and knob.

Deprecated
- highlight:

Highlights or unhighlights the scroll button the user clicked.

Deprecated

Event Handling

hitPart

A part code indicating the manner in which the scrolling should be performed.

- trackKnob:

Tracks the knob and sends action messages to the receiver’s target.

- trackScrollButtons:

Tracks the scroll buttons and sends action messages to the receiver’s target.

Deprecated

Setting Control Tint

controlTint

The scroller’s control tint.

Deprecated

Managing Presentation Style

preferredScrollerStyle

Returns the style of scrollers that applications should use wherever possible.

scrollerStyle

The scroller style for this scroller.

knobStyle

The scroller’s knob style.

Constants

NSScrollerStyle

Constants to specify the scroller style.

NSScrollerKnobStyle

Specify different knob styles.

NSScrollerPart

These constants specify the different parts of the scroller:

NSScrollerArrow

These constants describe the two scroller buttons and are used by drawArrow:highlight:.

Deprecated
NSScrollArrowPosition

These constants specify where the scroller’s buttons appear and are used by the arrowsPosition property.

Deprecated
NSUsableScrollerParts

These constants specify which parts of the scroller are visible.

Notifications

NSPreferredScrollerStyleDidChangeNotification

Posted if the preferred scroller style changes.

Instance Properties

knobProportion

The proportion of the knob slot that the knob should fill.

Relationships

Inherits From

See Also

Views

NSScrollView

A view that displays a portion of a document view and provides scroll bars that allow the user to move the document view within the scroll view.

NSClipView

An object that clips a document view to a scroll view's frame.