Mac Developer Library

Developer

AppKit Framework Reference NSSplitViewDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSSplitViewDelegate

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

Inheritance


Not Applicable

Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.6 and later.
  • Allows the delegate to specify custom sizing behavior for the subviews of the NSSplitView sender.

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, resizeSubviewsWithOldSize oldSize: NSSize)

    Objective-C

    - (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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

    See Also

    – adjustSubviews (NSSplitView)
    – setFrame: (NSView)

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

    Declaration

    Swift

    optional func splitViewWillResizeSubviews(_ aNotification: NSNotification)

    Objective-C

    - (void)splitViewWillResizeSubviews:(NSNotification *)aNotification

    Parameters

    aNotification

    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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func splitViewDidResizeSubviews(_ aNotification: NSNotification)

    Objective-C

    - (void)splitViewDidResizeSubviews:(NSNotification *)aNotification

    Parameters

    aNotification

    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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, canCollapseSubview subview: NSView) -> Bool

    Objective-C

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

    Parameters

    splitView

    The split view that sent the message.

    subview

    The subview to collapse.

    Return Value

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

    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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, shouldCollapseSubview subview: NSView, forDoubleClickOnDividerAtIndex dividerIndex: Int) -> Bool

    Objective-C

    - (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

    YEStrue if the subview should collapse, NOfalse 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 YEStrue when sent splitView:canCollapseSubview: for the subview in question. When the delegate indicates that both subviews should be collapsed NSSplitView's behavior is undefined.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, shouldAdjustSizeOfSubview subview: NSView) -> Bool

    Objective-C

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

    Parameters

    splitView

    The split view that sent the message.

    subview

    The subview to resize.

    Return Value

    YEStrue if adjustSubviews can change the size of the subview, otherwise NOfalse. By returning NOfalse, 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 YEStrue.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, effectiveRect proposedEffectiveRect: NSRect, forDrawnRect drawnRect: NSRect, ofDividerAtIndex dividerIndex: Int) -> NSRect

    Objective-C

    - (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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, shouldHideDividerAtIndex dividerIndex: Int) -> Bool

    Objective-C

    - (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

    YEStrue 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 NOfalse when sent this message.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, additionalEffectiveRectOfDividerAtIndex dividerIndex: Int) -> NSRect

    Objective-C

    - (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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, constrainMaxCoordinate proposedMax: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat

    Objective-C

    - (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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

    See Also

    – isVertical (NSSplitView)

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

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, constrainMinCoordinate proposedMin: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat

    Objective-C

    - (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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

    See Also

    – isVertical (NSSplitView)

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

    Declaration

    Swift

    optional func splitView(_ splitView: NSSplitView, constrainSplitPosition proposedPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat

    Objective-C

    - (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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.