Re: Restricting an NSSplitView when Resizing a Window
Re: Restricting an NSSplitView when Resizing a Window
- Subject: Re: Restricting an NSSplitView when Resizing a Window
- From: Brock Brandenberg <email@hidden>
- Date: Mon, 17 Feb 2003 23:02:10 -0600
Hi Tito.
>
The methods:
>
>
- splitView:constrainMaxCoordinate:ofSubviewAt:
>
- splitView:constrainMinCoordinate:ofSubviewAt:
>
>
are only called when I drag the NSSplitView. The behavior when I
>
manipulate the NSSplitView directly is fine. The problem shows up when
>
I resize the window: both NSTableViews grow with the window. The
>
behavior I'd like to implement is: top NSTableView stays as is, and the
>
bottom NSTableView grows as needed.
>
>
It seems I should restrict the NSSplitView's minimum size "as is" at
>
the time when the window resize starts, but I don't know how to
>
intercept the method call to lock the NSSplitView.
>
>
Any ideas?
>
You simply need to take over the resizing of its subviews when it changes
size :) Just implement the following delegate method to size your subviews
manually when the split view is resized (not divider moved):
- (void)splitView:(NSSplitView *)sender
resizeSubviewsWithOldSize:(NSSize)oldSize
By default, the above method simply calls -adjustSubviews which is
responsible for the proportional scaling you usually see. By overriding the
above method, you can set the size of your subviews yourself which will then
determine the position of the divider. Here's a quick example to get you
going that keeps the top view the same height while the bottom one changes
when the window is resized:
- (void)splitView:(NSSplitView *)sender
resizeSubviewsWithOldSize:(NSSize)oldSize
{
// IB outlets
// IBOutlet NSView *topView;
// IBOutlet NSView *bottomView;
NSSize splitViewSize = [sender frame].size;
NSSize topSize = [topView frame].size;
topSize.width = splitViewSize.width;
NSSize bottomSize;
bottomSize.width = splitViewSize.width;
bottomSize.height = splitViewSize.height - [sender dividerThickness] -
topSize.height;
[topView setFrameSize:topSize];
[bottomView setFrameSize:bottomSize];
}
Brock Brandenberg
----- industrial design @ www.bergdesign.com ------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.