#146 new
Patrick Crosby

CPSplitView doesn't honor splitView:constrainMinCoordinate:ofSubviewAt: when resizing window

Reported by Patrick Crosby | November 21st, 2008 @ 01:03 PM

If I have the following method in a CPSplitView delegate:


- (int)splitView:(CPSplitView)splitView constrainMinCoordinate:(int)minCoord ofSubviewAt:(int)index
{
    if (index == 0) {
        return 200;
    }
    else {
        return minCoord;
    }
}

it correctly keeps the subview at index 0 from ever being less than 200 pixels wide when moving the splitter around.

But if I resize the window and make the window smaller, the subview does get resized with a width less than 200 pixels...

I added a log message to the above method to check whether it ever gets called. When resizing the window, the method never gets called. It gets called plenty when moving the splitter.

Comments and changes to this ticket

  • Francisco Tolmasky

    Francisco Tolmasky November 21st, 2008 @ 03:44 PM

    The docs on Apple's page say the following:

    This method is invoked before the NSSplitView 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. proposedMin is specified in the NSSplitView’s flipped coordinate system. 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. offset specifies the divider the user is moving, with the first divider being 0 and going up from top to bottom (or left to right).

    So it sounds like it should only be called during repositioning of the divider. Could you possibly do a test against Cocoa to see whether this is actually the case?

  • Patrick Crosby

    Patrick Crosby November 21st, 2008 @ 07:10 PM

    Ok, I wrote a little cocoa app and this method does get called when the window is resized as well as when the divider is repositioned.

    I attached the project if you care to see for yourself...

  • Francisco Tolmasky

    Francisco Tolmasky November 21st, 2008 @ 08:12 PM

    Cool, I'll try to fix this tomorrow then

  • ronin-756 (at lighthouseapp)

    ronin-756 (at lighthouseapp) March 23rd, 2009 @ 10:27 PM

    • Tag changed from appkit, bug, cpsplitview to @acknowledged, appkit, bug, cpsplitview

    This hasn't been fixed in 0.7b yet. Here is a test case : http://gist.github.com/83999

  • daniel (at brajkovic)

    daniel (at brajkovic) May 27th, 2010 @ 05:55 AM

    I do not believe this is a bug. Cocoa's NSSplitView performs in the exact same manner (unfotunately).

    I think the proper solution is the delegate method splitViewDidResizeSubviews:

    For example, in my app, my constrained, min, and max positions are all 151, so I implemented the following delegate method.

    -(void) splitViewDidResizeSubviews:(CPNotification)notification {
        [splitView setPosition:151 ofDividerAtIndex:0];
    }
    

    Obviously, you can change this could to test the size of the resized subviews and if below a minimum or greater than a maximum, set the position of the divider accordingly. In Cocoa, I have found at least one framework that subclassed NSSplitView to handle this with attributes instead of a delegate. See http://brandonwalkin.com/bwtoolkit/ The source code is included.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Cappuccino Web Framework, including AppKit, Foundation, and Objective-J.

Shared Ticket Bins

People watching this ticket

Attachments

Pages