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: Generic User <email@hidden>
- Date: Mon, 17 Feb 2003 23:18:42 -0600
>
Use the delegate methods for the NSSplitView:
>
>
- splitView:constrainMaxCoordinate:ofSubviewAt:
>
- splitView:constrainMinCoordinate:ofSubviewAt:
>
- splitView:constrainSplitPosition:ofSubviewAt:
>
>
You can limit the lower bounds, upper bounds or restrict it to specific
>
positions. Just wire your split view delegate connection to a delegate
>
object in IB, then implement the methods in the delegate object with
>
your
>
desired behavior.
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?
Thanks,
-- Tito
I don't remember which one of you asked this but here is what I do.
@implementation YourCustomView
- (void)setFrameSize:(NSSize)newSize
{
if (newSize.height>295) newSize.height=295;
[super setFrameSize:newSize];
}
@end
Subclass NSView (Easy to do since the new file menu has a template for
you).
Override setFrameSize: as above (only change the actual numbers and
change height to width if your splitview is horizontal.
Oh, then go to classes, read files in IB, read YourCustomView.h, then
set the class of the particular view to YourCustomView in the inspector.
The other view (in the splitview) can be normal, unless you also want
to restrict it in some way.
Now, when the window is resized, the view is guaranteed (I think) to
have its setFrameSize: method called. So your class intercepts and
restricts the max/min size.
cheesy but it works. It just gets ugly when your project has many
dozens of these little subclasses. I thought Cocoa was supposed to
eliminate that need!! Maybe there is another way, one that is elegant
but I just don't know. I usually just forge ahead, don't have time to
figure out any other way.
I hope this is what you were looking for.
dan
_______________________________________________
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.