16

I have an NSSplitView (NO UISplitView(Controller)!!) with three subviews. Now, for the last divider (index 1), I want the divider to not show the dragging cursor (two arrows pointing out of eachother). I have this to stop the dragging, but the cursor is still showing up:

- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex {
  if (dividerIndex == 1) {
    return [splitView frame].size.width - 161;
  }
}

Note that I only want to hide the cursor for the divider at index 1. Can anyone help me? Thanks. :)


No, I don't want to use BWToolkit.

General Grievance
  • 4,555
  • 31
  • 31
  • 45

2 Answers2

82

I know this has been answered for a while, but the supplied answer did not suit my needs.

The delegate method splitView:effectiveRect:forDrawnRect:ofDividerAtIndex: allows you to set the effective rectangle for dragging the divider. If you return NSZeroRect no drag cursor will ever appear, regardless of your setup in splitView:constrainMaxCoordinate:ofSubviewAt: and splitView:constrainMinCoordinate:ofSubviewAt:.

starball
  • 20,030
  • 7
  • 43
  • 238
Mike A
  • 2,501
  • 2
  • 23
  • 30
  • 1
    This works perfect to prevent the resize cursor from appearing even when using Auto Layout to manage the split view! Thanks! – Andrew Nov 09 '12 at 22:18
  • I couldn’t entirely hide the dividers using this technique and instead got phantom disconnected dividers. Overriding the dividerThickness property of NSSplitView to return 0.0 did the trick (see http://stackoverflow.com/a/29049380/253485) – Aral Balkan Mar 14 '15 at 13:19
  • How do you set this for just one divider and allow the others to operate normally? – Clifton Labrum Dec 22 '16 at 03:28
0

Try using splitView:constrainMaxCoordinate:ofSubviewAt: and splitView:constrainMinCoordinate:ofSubviewAt: instead of splitView:constrainSplitPosition:ofSubviewAt:.

The former two methods are called once as the user drags the mouse and they give enough information for NSSplitView to know how to change the cursor during the drag.

The latter is called repeatedly as the user drags the splitter, so NSSplitView doesn't have enough information to know that you're returning a constant value each time and therefore can't change the cursor.

kperryua
  • 10,524
  • 1
  • 38
  • 24