NSSplitViewDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.6 and later.
Declared in
NSSplitView.h
Companion guides
Related sample code

Overview

The NSSplitViewDelegate protocol defines the optional methods implemented by delegates of NSSplitView objects.

Tasks

Managing Subviews

Configuring and Drawing View Dividers

Constraining Split Position

Instance Methods

splitView:additionalEffectiveRectOfDividerAtIndex:

Allows the delegate to return an additional rectangle in which mouse clicks will initiate divider dragging.

- (NSRect)splitView:(NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex:(NSInteger)dividerIndex
Parameters
splitView

The split view that sent the message.

dividerIndex

The index of the divider.

Return Value

An additional rectangle in which mouse clicks should initiate divider dragging. The rectangle should be expressed in the coordinate system defined by splitView. Returning NSZeroRect indicates no additional dragging rectangle is desired.

Discussion

If a split view has no delegate, or if its delegate does not respond to this message, only mouse clicks within the effective frame of a divider initiate divider dragging.

Availability
  • Available in OS X v10.5 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSSplitView.h

splitView:canCollapseSubview:

Allows the delegate to determine whether the user can collapse and uncollapse subview.

- (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview
Parameters
splitView

The split view that sent the message.

subview

The subview to collapse.

Return Value

YES if subview should collapse when the user drags a divider beyond the halfway mark between its minimum size and its edge, otherwise NO.

Discussion

The subview uncollapses when the user drags the divider back beyond the halfway mark between its minimum size and its edge.

To specify the minimum size, define the methods splitView:constrainMaxCoordinate:ofSubviewAt: and splitView:constrainMinCoordinate:ofSubviewAt:. A subview can collapse only if you also define splitView:constrainMinCoordinate:ofSubviewAt:.

A collapsed subview is hidden but retained by the split view object, with the same size it had before it was collapsed.

If the delegate does not implement this method the subviews can’t be collapsed.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSSplitView.h

splitView:constrainMaxCoordinate:ofSubviewAt:

Allows the delegate for sender to constrain the maximum coordinate limit of a divider when the user drags it.

- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex
Parameters
splitView

The split view that sent the message.

proposedMax

The proposed maximum coordinate limit of the subview, in the split view’s flipped coordinate system.

dividerIndex

Specifies the divider the user is moving, with the first divider being 0 and increasing from top to bottom (or left to right).

Return Value

The maximum coordinate limit of the divider.

Discussion

This method is invoked before the split view begins tracking the mouse to position a divider. You may further constrain the limits that have been already set, but you cannot extend the divider limits.

If the split bars are horizontal (views are one on top of the other), proposedMax is the bottom limit. If the split bars are vertical (views are side by side), proposedMax is the right limit. The initial value of proposedMax is the bottom (or right side) of the subview after the divider.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSSplitView.h

splitView:constrainMinCoordinate:ofSubviewAt:

Allows the delegate for sender to constrain the minimum coordinate limit of a divider when the user drags it.

- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex
Parameters
splitView

The split view that sent the message.

proposedMin

The proposed minimum coordinate limit of the subview, in the split view’s flipped coordinate system.

dividerIndex

Specifies the divider the user is moving, with the first divider being 0 and increasing from top to bottom (or left to right).

Return Value

The minimum coordinate limit of the divider.

Discussion

This method is invoked before the split view begins tracking the cursor to position a divider. You may further constrain the limits that have been already set, but you cannot extend the divider limits.

If the split bars are horizontal (views are one on top of the other), proposedMin is the top limit. If the split bars are vertical (views are side by side), proposedMin is the left limit. The initial value of proposedMin is the top (or left side) of the subview before the divider.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSSplitView.h

splitView:constrainSplitPosition:ofSubviewAt:

Allows the delegate for sender to constrain the divider to certain positions.

- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex
Parameters
splitView

The split view that sent the message.

proposedPosition

The cursor’s current position, and the proposed position of the divider.

dividerIndex

Specifies the divider the user is moving, with the first divider being 0 and increasing from top to bottom (or left to right).

Return Value

The position at which to constrain the divider.

Discussion

If the delegate implements this method, the split view calls it repeatedly as the user moves the divider.

For example, if a subview’s height must be a multiple of a certain number, use this method to return the multiple nearest to proposedPosition.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSSplitView.h

splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:

Allows the delegate to modify the rectangle in which mouse clicks initiate divider dragging.

- (NSRect)splitView:(NSSplitView *)splitView effectiveRect:(NSRect)proposedEffectiveRect forDrawnRect:(NSRect)drawnRect ofDividerAtIndex:(NSInteger)dividerIndex
Parameters
splitView

The split view that sent the message.

proposedEffectiveRect

The proposed rectangle in which mouse clicks should initiate divider dragging. The rectangle is expressed in the coordinate system defined by splitView.

drawnRect

The frame of the divider, expressed in the coordinate system defined by splitView.

dividerIndex

The index of the divider.

Return Value

The rectangle in which mouse clicks should initiate divider dragging. The rectangle should be expressed in the coordinate system defined by splitView.

Discussion

A split view with thick dividers proposes the drawn frame as the effective frame. A split view with thin dividers proposes an effective frame that's a little larger than the drawn frame, to make it easier for the user to actually grab the divider.

If a split view has no delegate, or if its delegate does not respond to this message, the split view behaves as if it has a delegate that returns proposedEffectiveRect when sent this message.

Availability
  • Available in OS X v10.5 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSSplitView.h

splitView:resizeSubviewsWithOldSize:

Allows the delegate to specify custom sizing behavior for the subviews of the NSSplitView sender.

- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize
Parameters
splitView

The split view that sent the message.

oldSize

The size of the split view before the user resized it.

Discussion

If the delegate implements this method, splitView:resizeSubviewsWithOldSize: is invoked after the split view is resized.

The subviews should be resized such that the sum of the sizes of the subviews plus the sum of the thickness of the dividers equals the size of the NSSplitView’s new frame. You can get the thickness of a divider through the dividerThickness method.

Note that if you implement this delegate method to resize subviews on your own, the NSSplitView does not perform any error checking for you. However, you can invoke adjustSubviews to perform the default sizing behavior.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSSplitView.h

splitView:shouldAdjustSizeOfSubview:

Allows the delegate to specify whether the subview should be resized.

- (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)subview
Parameters
splitView

The split view that sent the message.

subview

The subview to resize.

Return Value

YES if adjustSubviews can change the size of the subview, otherwise NO. By returning NO, you lock the size of the split view subview while the split view is resized.

Discussion

Regardless of the value returned by this method, adjustSubviews may change the origin of the subview. Otherwise non-resizable subviews may also be resized in order to prevent an invalid subview layout.

If a split view has no delegate, or if its delegate does not respond to this message, the split view behaves as if this method returns YES.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSSplitView.h

splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:

Invoked to allow a delegate to determine if a subview should collapse in response to a double click.

- (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex
Parameters
splitView

The split view that sent the message.

subview

The subview to collapse.

dividerIndex

The index of the divider.

Return Value

YES if the subview should collapse, NO otherwise.

Discussion

If implemented, the delegate will receive this message once for the subview before a divider when the user double-clicks on that divider, and again for the subview after the divider, but only if the delegate returned YES when sent splitView:canCollapseSubview: for the subview in question. When the delegate indicates that both subviews should be collapsed NSSplitView's behavior is undefined.

Availability
  • Available in OS X v10.5 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSSplitView.h

splitView:shouldHideDividerAtIndex:

Allows the delegate to determine whether a divider can be dragged or adjusted off the edge of the split view.

- (BOOL)splitView:(NSSplitView *)splitView shouldHideDividerAtIndex:(NSInteger)dividerIndex
Parameters
splitView

The split view that sent the message.

dividerIndex

The zero-based index of the divider.

Return Value

YES if the divider should allow dragging off the edge of the split view, resulting in it not being visible.

Discussion

If a split view has no delegate, or if its delegate does not respond to this message, the split view behaves as if it has a delegate that returns NO when sent this message.

Availability
  • Available in OS X v10.5 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSSplitView.h

splitViewDidResizeSubviews:

Invoked by the default notification center to notify the delegate that the splitview did resize its subviews.

- (void)splitViewDidResizeSubviews:(NSNotification *)aNotification
Parameters
aNotification

A notification named NSSplitViewDidResizeSubviewsNotification.

Discussion

If the delegate implements this method, the delegate is automatically registered to receive this notification.

This method is invoked after the split view resizes two of its subviews in response to the repositioning of a divider.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSSplitView.h

splitViewWillResizeSubviews:

Invoked by the default notification center to notify the delegate that the splitview will resize its subviews.

- (void)splitViewWillResizeSubviews:(NSNotification *)aNotification
Parameters
aNotification

A notification named NSSplitViewWillResizeSubviewsNotification.

Discussion

If the delegate implements this method, the delegate is automatically registered to receive this notification.

This method is invoked before the split view resizes two of its subviews in response to the repositioning of a divider.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSSplitView.h