Re: NSSplitView autoresize only 1 of the 2 custom views
Re: NSSplitView autoresize only 1 of the 2 custom views
- Subject: Re: NSSplitView autoresize only 1 of the 2 custom views
- From: Peter Borg <email@hidden>
- Date: Wed, 9 Jan 2008 19:55:17 +0100
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden