Trouble with NSSplitView

  • Hi,

    I have set up in IB a window with 3 split views. The main split view
    (with a vertical divider) contains 2 splits (horizontal divider):

    **************************************
    *    *              3              *
    *  1  ********************************
    *    *                              *
    *    *                              *
    *******              4              *
    *    *                              *
    *  2  *                              *
    **************************************

    I'm using an NSViewController subclass (with an associated nib) for
    each of the views. In the - windowDidLoad: method of my
    NSWindowController subclass, I set dividers positions and add each
    view, resizing it according to the size available in each pane. I'm
    testing this interface so all views contain dummy controls:

    1- has only buttons
    2- has only a Date picker in calendar form
    3- has a multiline text view (with scroller) and 2 buttons.
    4- has a NSTableView

    At launch, everything is good and I've no problem changing the
    splitter's position between pane 1 and 2 or with the vertical divider.
    Now, if I change the splitter's position between pane 3 and 4 all the
    way up or down and back, the header of the NSTableView and the top of
    the text view, become hidden (under the divider). I've tried many
    combinations of resize/lock for these views in IB, played various
    constants with -setAutoresizingMask:. No luck. Either I'm missing the
    good one, or I'm in the wrong track. This is driving me nuts, any
    advice on getting the good combination?

    Thanks,

    Andre Masse
  • I had the same problem. The fix was to recreate the view in IB. Seems
    to be a bug in IB, but I never tried to repeat the problem once it
    was fixed.

    Dave

    On Oct 7, 2008, at 5:41 PM, Andre Masse wrote:

    > Hi,
    >
    > I have set up in IB a window with 3 split views. The main split
    > view (with a vertical divider) contains 2 splits (horizontal divider):
    >
    > **************************************
    > *    *              3              *
    > *  1  ********************************
    > *    *                              *
    > *    *                              *
    > *******              4              *
    > *    *                              *
    > *  2  *                              *
    > **************************************
    >
    > I'm using an NSViewController subclass (with an associated nib) for
    > each of the views. In the - windowDidLoad: method of my
    > NSWindowController subclass, I set dividers positions and add each
    > view, resizing it according to the size available in each pane. I'm
    > testing this interface so all views contain dummy controls:
    >
    > 1- has only buttons
    > 2- has only a Date picker in calendar form
    > 3- has a multiline text view (with scroller) and 2 buttons.
    > 4- has a NSTableView
    >
    >
    > At launch, everything is good and I've no problem changing the
    > splitter's position between pane 1 and 2 or with the vertical
    > divider. Now, if I change the splitter's position between pane 3
    > and 4 all the way up or down and back, the header of the
    > NSTableView and the top of the text view, become hidden (under the
    > divider). I've tried many combinations of resize/lock for these
    > views in IB, played various constants with -setAutoresizingMask:.
    > No luck. Either I'm missing the good one, or I'm in the wrong
    > track. This is driving me nuts, any advice on getting the good
    > combination?
    >
    > Thanks,
    >
    > Andre Masse
  • Tried your suggestion and it worked... almost. I now have trouble with
    the buttons under the text view. If I bring the divider all the way
    up, I need to bring the divider farther than it was to display the
    buttons. For example, if the divider was at 200 pixels from the top
    before "closing" it, I need to bring it down at 400 for the buttons to
    show up. I have no idea what's going on here... I'm surely doing
    something bad cause this kind of interface is pretty common on the
    Mac...

    Thanks for your suggestion though, it solved a good part of my problem,

    Andre Masse

    On Oct 7, 2008, at 19:44, Dave Fernandes wrote:

    > I had the same problem. The fix was to recreate the view in IB.
    > Seems to be a bug in IB, but I never tried to repeat the problem
    > once it was fixed.
    >
    > Dave
  • Is the part of the view with the buttons inside an NSScrollView? It
    should be scrollable if you are going to resize it with the
    splitview. If it is not scrollable, then you will have the problem
    you describe.

    Dave

    On Oct 7, 2008, at 8:59 PM, Andre Masse wrote:

    > Tried your suggestion and it worked... almost. I now have trouble
    > with the buttons under the text view. If I bring the divider all
    > the way up, I need to bring the divider farther than it was to
    > display the buttons. For example, if the divider was at 200 pixels
    > from the top before "closing" it, I need to bring it down at 400
    > for the buttons to show up. I have no idea what's going on here...
    > I'm surely doing something bad cause this kind of interface is
    > pretty common on the Mac...
    >
    > Thanks for your suggestion though, it solved a good part of my
    > problem,
    >
    > Andre Masse
    >
    >
    > On Oct 7, 2008, at 19:44, Dave Fernandes wrote:
    >
    >> I had the same problem. The fix was to recreate the view in IB.
    >> Seems to be a bug in IB, but I never tried to repeat the problem
    >> once it was fixed.
    >>
    >> Dave

  • On Oct 7, 2008, at 4:44 PM, Dave Fernandes wrote:

    > I had the same problem. The fix was to recreate the view in IB.
    > Seems to be a bug in IB, but I never tried to repeat the problem
    > once it was fixed.

    This isn't a problem with IB, it also isn't unique to split views.

    The problem has to do with how the autoresizing rules used by NSView
    are applied. They're applied as scaled deltas from previous values,
    and when you fully collapse a split view, you have a view size that
    goes to zero, and all of the scaling then clamps to zero (zero times
    anything is zero).

    To deal with this, this you should use the NSSplitView delegate
    methods to prevent the view from getting smaller than some minimum
    size. The typical behavior is to have the split view resizing towards
    the minimum, when it gets to that minimum it stops resizing even as
    the user continues to drag the mouse. Once the user drags the mouse
    all of the way, the view completely collapses. Behind the scenes,
    NSSplitView doesn't make the subview any smaller than the minimum
    size, but that isn't evident to the user.

    You can see this behavior in Mail. Open a Mail window, and then drag
    the split bar that splits the messages table and the message
    composition view. When the split bar gets to about 100 points from the
    bottom of the window it stops moving. If you keep dragging, the
    splitter eventual jumps the remaining distance.

    Jon Hess

    >
    >
    > Dave
    >
    > On Oct 7, 2008, at 5:41 PM, Andre Masse wrote:
    >
    >> Hi,
    >>
    >> I have set up in IB a window with 3 split views. The main split
    >> view (with a vertical divider) contains 2 splits (horizontal
    >> divider):
    >>
    >> **************************************
    >> *    *              3              *
    >> *  1  ********************************
    >> *    *                              *
    >> *    *                              *
    >> *******              4              *
    >> *    *                              *
    >> *  2  *                              *
    >> **************************************
    >>
    >> I'm using an NSViewController subclass (with an associated nib) for
    >> each of the views. In the - windowDidLoad: method of my
    >> NSWindowController subclass, I set dividers positions and add each
    >> view, resizing it according to the size available in each pane. I'm
    >> testing this interface so all views contain dummy controls:
    >>
    >> 1- has only buttons
    >> 2- has only a Date picker in calendar form
    >> 3- has a multiline text view (with scroller) and 2 buttons.
    >> 4- has a NSTableView
    >>
    >>
    >> At launch, everything is good and I've no problem changing the
    >> splitter's position between pane 1 and 2 or with the vertical
    >> divider. Now, if I change the splitter's position between pane 3
    >> and 4 all the way up or down and back, the header of the
    >> NSTableView and the top of the text view, become hidden (under the
    >> divider). I've tried many combinations of resize/lock for these
    >> views in IB, played various constants with -setAutoresizingMask:.
    >> No luck. Either I'm missing the good one, or I'm in the wrong
    >> track. This is driving me nuts, any advice on getting the good
    >> combination?
    >>
    >> Thanks,
    >>
    >> Andre Masse

  • Thanks a lot for the explanation Jon. This makes it clear now. Thanks
    also to Dave. It was good to know I wasn't the only one struggling
    with this.

    Andre Masse

    On Oct 7, 2008, at 22:43, Jonathan Hess wrote:

    > On Oct 7, 2008, at 4:44 PM, Dave Fernandes wrote:
    >
    >> I had the same problem. The fix was to recreate the view in IB.
    >> Seems to be a bug in IB, but I never tried to repeat the problem
    >> once it was fixed.
    >
    > This isn't a problem with IB, it also isn't unique to split views.
    >
    > The problem has to do with how the autoresizing rules used by NSView
    > are applied. They're applied as scaled deltas from previous values,
    > and when you fully collapse a split view, you have a view size that
    > goes to zero, and all of the scaling then clamps to zero (zero times
    > anything is zero).
    >
    > To deal with this, this you should use the NSSplitView delegate
    > methods to prevent the view from getting smaller than some minimum
    > size. The typical behavior is to have the split view resizing
    > towards the minimum, when it gets to that minimum it stops resizing
    > even as the user continues to drag the mouse. Once the user drags
    > the mouse all of the way, the view completely collapses. Behind the
    > scenes, NSSplitView doesn't make the subview any smaller than the
    > minimum size, but that isn't evident to the user.
    >
    > You can see this behavior in Mail. Open a Mail window, and then drag
    > the split bar that splits the messages table and the message
    > composition view. When the split bar gets to about 100 points from
    > the bottom of the window it stops moving. If you keep dragging, the
    > splitter eventual jumps the remaining distance.
    >
    > Jon Hess
  • Hi Jon,
    Given your explanation, I now don't understand why my split view
    works at all. I can resize my views to zero and back up again without
    having to jump to zero after reaching the minimum size.

    Another question: what does Mail do when it jumps to zero? Does it
    remove the subview from the split view?

    Dave

    On Oct 7, 2008, at 10:43 PM, Jonathan Hess wrote:

    > On Oct 7, 2008, at 4:44 PM, Dave Fernandes wrote:
    >
    >> I had the same problem. The fix was to recreate the view in IB.
    >> Seems to be a bug in IB, but I never tried to repeat the problem
    >> once it was fixed.
    >
    > This isn't a problem with IB, it also isn't unique to split views.
    >
    > The problem has to do with how the autoresizing rules used by
    > NSView are applied. They're applied as scaled deltas from previous
    > values, and when you fully collapse a split view, you have a view
    > size that goes to zero, and all of the scaling then clamps to zero
    > (zero times anything is zero).
    >
    > To deal with this, this you should use the NSSplitView delegate
    > methods to prevent the view from getting smaller than some minimum
    > size. The typical behavior is to have the split view resizing
    > towards the minimum, when it gets to that minimum it stops resizing
    > even as the user continues to drag the mouse. Once the user drags
    > the mouse all of the way, the view completely collapses. Behind the
    > scenes, NSSplitView doesn't make the subview any smaller than the
    > minimum size, but that isn't evident to the user.
    >
    > You can see this behavior in Mail. Open a Mail window, and then
    > drag the split bar that splits the messages table and the message
    > composition view. When the split bar gets to about 100 points from
    > the bottom of the window it stops moving. If you keep dragging, the
    > splitter eventual jumps the remaining distance.
    >
    > Jon Hess
    >
    >>
    >>
    >> Dave
    >>
    >> On Oct 7, 2008, at 5:41 PM, Andre Masse wrote:
    >>
    >>> Hi,
    >>>
    >>> I have set up in IB a window with 3 split views. The main split
    >>> view (with a vertical divider) contains 2 splits (horizontal
    >>> divider):
    >>>
    >>> **************************************
    >>> *    *              3              *
    >>> *  1  ********************************
    >>> *    *                              *
    >>> *    *                              *
    >>> *******              4              *
    >>> *    *                              *
    >>> *  2  *                              *
    >>> **************************************
    >>>
    >>> I'm using an NSViewController subclass (with an associated nib)
    >>> for each of the views. In the - windowDidLoad: method of my
    >>> NSWindowController subclass, I set dividers positions and add
    >>> each view, resizing it according to the size available in each
    >>> pane. I'm testing this interface so all views contain dummy
    >>> controls:
    >>>
    >>> 1- has only buttons
    >>> 2- has only a Date picker in calendar form
    >>> 3- has a multiline text view (with scroller) and 2 buttons.
    >>> 4- has a NSTableView
    >>>
    >>>
    >>> At launch, everything is good and I've no problem changing the
    >>> splitter's position between pane 1 and 2 or with the vertical
    >>> divider. Now, if I change the splitter's position between pane 3
    >>> and 4 all the way up or down and back, the header of the
    >>> NSTableView and the top of the text view, become hidden (under
    >>> the divider). I've tried many combinations of resize/lock for
    >>> these views in IB, played various constants with -
    >>> setAutoresizingMask:. No luck. Either I'm missing the good one,
    >>> or I'm in the wrong track. This is driving me nuts, any advice on
    >>> getting the good combination?
    >>>
    >>> Thanks,
    >>>
    >>> Andre Masse

    >
  • On Oct 8, 2008, at 4:59 AM, Dave Fernandes wrote:

    > Hi Jon,
    > Given your explanation, I now don't understand why my split view
    > works at all. I can resize my views to zero and back up again
    > without having to jump to zero after reaching the minimum size.
    >
    > Another question: what does Mail do when it jumps to zero? Does it
    > remove the subview from the split view?

    Hey Dave -

    The split view keeps the collapsed view's bounds from ever reaching
    size zero. The documentation for the split view delegate covers, this.
    There are also great comments in the header for NSSplitView.h.

    The relevant delegate methods are:

    - [NSObject splitView:canCollapseSubview:];
    - [NSObject splitView:constrainMinCoordinate:ofSubviewAt:];
    - [NSObject splitView:constrainMaxCoordinate:ofSubviewAt:];

    Here's a link to the relevant split view docs:
    http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Cla
    sses/NSSplitView_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObj
    ect/splitView:canCollapseSubview
    :

    Good Luck -
    Jon Hess

    >
    >
    > Dave
    >
    > On Oct 7, 2008, at 10:43 PM, Jonathan Hess wrote:
    >
    >> On Oct 7, 2008, at 4:44 PM, Dave Fernandes wrote:
    >>
    >>> I had the same problem. The fix was to recreate the view in IB.
    >>> Seems to be a bug in IB, but I never tried to repeat the problem
    >>> once it was fixed.
    >>
    >> This isn't a problem with IB, it also isn't unique to split views.
    >>
    >> The problem has to do with how the autoresizing rules used by
    >> NSView are applied. They're applied as scaled deltas from previous
    >> values, and when you fully collapse a split view, you have a view
    >> size that goes to zero, and all of the scaling then clamps to zero
    >> (zero times anything is zero).
    >>
    >> To deal with this, this you should use the NSSplitView delegate
    >> methods to prevent the view from getting smaller than some minimum
    >> size. The typical behavior is to have the split view resizing
    >> towards the minimum, when it gets to that minimum it stops resizing
    >> even as the user continues to drag the mouse. Once the user drags
    >> the mouse all of the way, the view completely collapses. Behind the
    >> scenes, NSSplitView doesn't make the subview any smaller than the
    >> minimum size, but that isn't evident to the user.
    >>
    >> You can see this behavior in Mail. Open a Mail window, and then
    >> drag the split bar that splits the messages table and the message
    >> composition view. When the split bar gets to about 100 points from
    >> the bottom of the window it stops moving. If you keep dragging, the
    >> splitter eventual jumps the remaining distance.
    >>
    >> Jon Hess
    >>
    >>>
    >>>
    >>> Dave
    >>>
    >>> On Oct 7, 2008, at 5:41 PM, Andre Masse wrote:
    >>>
    >>>> Hi,
    >>>>
    >>>> I have set up in IB a window with 3 split views. The main split
    >>>> view (with a vertical divider) contains 2 splits (horizontal
    >>>> divider):
    >>>>
    >>>> **************************************
    >>>> *    *              3              *
    >>>> *  1  ********************************
    >>>> *    *                              *
    >>>> *    *                              *
    >>>> *******              4              *
    >>>> *    *                              *
    >>>> *  2  *                              *
    >>>> **************************************
    >>>>
    >>>> I'm using an NSViewController subclass (with an associated nib)
    >>>> for each of the views. In the - windowDidLoad: method of my
    >>>> NSWindowController subclass, I set dividers positions and add
    >>>> each view, resizing it according to the size available in each
    >>>> pane. I'm testing this interface so all views contain dummy
    >>>> controls:
    >>>>
    >>>> 1- has only buttons
    >>>> 2- has only a Date picker in calendar form
    >>>> 3- has a multiline text view (with scroller) and 2 buttons.
    >>>> 4- has a NSTableView
    >>>>
    >>>>
    >>>> At launch, everything is good and I've no problem changing the
    >>>> splitter's position between pane 1 and 2 or with the vertical
    >>>> divider. Now, if I change the splitter's position between pane 3
    >>>> and 4 all the way up or down and back, the header of the
    >>>> NSTableView and the top of the text view, become hidden (under
    >>>> the divider). I've tried many combinations of resize/lock for
    >>>> these views in IB, played various constants with -
    >>>> setAutoresizingMask:. No luck. Either I'm missing the good one,
    >>>> or I'm in the wrong track. This is driving me nuts, any advice on
    >>>> getting the good combination?
    >>>>
    >>>> Thanks,
    >>>>
    >>>> Andre Masse

    >>