Skip navigation.
 
mlRe: NSSplitView autoresize only 1 of the 2 custom views
FROM : Peter Borg
DATE : Wed Jan 09 19:55:17 2008

On 9 jan 2008, at 19.13, Steven Crosley wrote:

> Is there a way to get NSSplitView to only resize 1 of the views when 
> expanding a window?
>
> This would work similarly to Finder or iTunes where the left view 
> would stay fixed in width but the right view would expand when 
> resizing a window.  I've played around with the autoresizes subviews 
> checkbox, but haven't been able to work it successfully.
>


Hi!

I think you have to do this with code. Put something like this in your 
NSSplitView delegate:

- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:
(NSSize)oldSize
{    
    CGFloat dividerThickness = [sender dividerThickness];
    NSRect leftRect  = [[[sender subviews] objectAtIndex:0] frame];
    NSRect rightRect = [[[sender subviews] objectAtIndex:1] frame];
    NSRect newFrame  = [sender frame];
   
    leftRect.size.height = newFrame.size.height;
    leftRect.origin = NSMakePoint(0, 0);
    rightRect.size.width = newFrame.size.width - leftRect.size.width 
- dividerThickness;
    rightRect.size.height = newFrame.size.height;
    rightRect.origin.x = leftRect.size.width + dividerThickness;
   
    [[[sender subviews] objectAtIndex:0] setFrame:leftRect];
    [[[sender subviews] objectAtIndex:1] setFrame:rightRect];
}

Cheers,

Peter

Related mailsAuthorDate
mlNSSplitView autoresize only 1 of the 2 custom views Steven Crosley Jan 9, 19:13
mlRe: NSSplitView autoresize only 1 of the 2 custom views Peter Borg Jan 9, 19:55