Re: Collapsing/expanding NSSplitView
Re: Collapsing/expanding NSSplitView
- Subject: Re: Collapsing/expanding NSSplitView
- From: Jeremy Dronfield <email@hidden>
- Date: Mon, 26 Jan 2004 12:13:34 +0000
On 25 Jan 2004, at 10:40 pm, Daniel Todd Currie wrote:
As I understand it, the sizes of the constituent views of an
NSSplitView are set simply by adjusting the size of either of the
views. If you want to "collapse" the NSSplitView, just set the
width/height to 0 for the view you would like to hide. The API
handles the resizing of the other view.
What I want ideally is for the divider (and its splitter thumb) to
disappear and reappear (as in iTunes, AddressBook etc). In order to
achieve this, I'm using the following crude workaround: subclassing
NSSplitView and returning 0 for -dividerThickness (which means I lose
the divider altogether) and implementing the collapse/uncollapse like
so:
- (IBAction)showHideBrowser:(id)sender
{
NSView *browser;
NSSize preservedSize;
float preservedHeight, currentWidth, newWidth;
browser = [[splitView subviews] objectAtIndex:1];
preservedSize = [browser frame].size;
preservedHeight = preservedSize.height;
currentWidth = preservedSize.width;
if (currentWidth == 0) {
newWidth = 220; //or whatever
} else {
newWidth = 0;
}
[browser setFrameSize:NSMakeSize(newWidth, preservedHeight)];
[splitView display];
}
Crude, because without the divider the user cannot resize the subview.
Given this as a starting point, I need a way of dynamically altering
the thickness of the divider to make it disappear/reappear.
-Jeremy
========================================
email@hidden
theLocustFarm.net:
- fractious fiction at
http://freespace.virgin.net/jeremy.dronfield
========================================
_______________________________________________
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.