Class

NSScroller

An NSScroller object controls scrolling of a document view within the clip view of an NSScrollView instance (or potentially of another kind of container view). 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.

Overview

Prior to OS X v10.7, an NSScroller object can also optionally display scroll buttons. The scroll buttons are a pair of buttons that the user can click to scroll by a small amount (called a line increment or decrement) and Alt-click to scroll by a large amount (called a page increment or decrement).

You normally don’t need to program with scrollers; instead, you typically 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.

Symbols

Managing Overlay Style Compatibility

class func isCompatibleWithOverlayScrollers()

Returns a Boolean value that indicates whether the class is compatible with overlay scroller style and behavior.

Determining Scroller Size

class func scrollerWidth(for: NSControlSize, scrollerStyle: NSScrollerStyle)

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

var controlSize: NSControlSize

The size of the scroller.

Laying out a Scroller

var arrowsPosition: NSScrollArrowPosition

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

Calculating Layout

func rect(for: NSScrollerPart)

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

func testPart(NSPoint)

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

func checkSpaceForParts()

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

var usableParts: NSUsableScrollerParts

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

Drawing Scroller Parts

func drawArrow(NSScrollerArrow, highlight: Bool)

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

func drawKnobSlot(in: NSRect, highlight: Bool)

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

func drawKnob()

Draws the knob.

func highlight(Bool)

Highlights or unhighlights the scroll button the user clicked.

Event Handling

var hitPart: NSScrollerPart

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

func trackKnob(with: NSEvent)

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

func trackScrollButtons(with: NSEvent)

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

Setting Control Tint

var controlTint: NSControlTint

The scroller’s control tint.

Managing Presentation Style

class func preferredScrollerStyle()

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

var scrollerStyle: NSScrollerStyle

The scroller style for this scroller.

var knobStyle: NSScrollerKnobStyle

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:).

NSScrollArrowPosition

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

NSUsableScrollerParts

These constants specify which parts of the scroller are visible.

Notifications

static let NSPreferredScrollerStyleDidChange: NSNotification.Name

Posted if the preferred scroller style changes.

Instance Properties

var knobProportion: CGFloat

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

Relationships

Inherits From

Conforms To