1

I have an NSSplitView with two subviews. My goal is to have each subview restricted to a minimum width but have the window's minimum width depend on which of the subviews is visible.

So for example, if the left/sidebar subview (with a min width of say 100) is collapsed then the window is permitted to resize all the way down to the right/main subview's min width (say 200). I have that part working for the most part. The part that I haven't been able to figure out is: when the left/sidebar is uncollapsed (either by dragging or double-clicking), the window width should increase to allow space for the left and right views (i.e. a minimum of 100 + 200 + divider).

Can anyone point me in the right direction? Thanks.

benb
  • 11
  • 1

1 Answers1

0

If what you want to know is how to set the window min width programmatically, you'll have to do it manually, which means updating the window frame and min size when the user witches view. Documentation

Depending in your needs, this blog post may also be of help to you.

Oscar Del Ben
  • 4,485
  • 1
  • 27
  • 41
  • Thanks, Oscar. I get how to set the min window width and frame programmatically, but I don't know where to do it in the case I described (i.e. when a subview is being revealed/uncollapsed). The closest I've come is using NSSplitViewDelegate's splitViewWillResizeSubviews: which is called when dragging the subview open, but setting the window's frame wider there leaves the window in a bizarre state where the split view's views don't fill the new wider window (also, that delegate method isn't called when double-clicking to open the subview). – benb Sep 16 '11 at 20:20