Re: expanding the view area of a window - please help
Re: expanding the view area of a window - please help
- Subject: Re: expanding the view area of a window - please help
- From: Kurt Revis <email@hidden>
- Date: Mon, 18 Mar 2002 08:27:33 -0800
On Monday, March 18, 2002, at 07:34 AM, Manuel Arturo Marques Pita
wrote:
What I'd like to do for ths second option (customise) is to have the
same
thing they implement in applications such as Illustrator in which at the
botton of a window/panel there is a long rectangular button that
expands that
window and shows more detailed controls. Pressing the button again
collapses
the window to its original state, this happens in a nice animated
fashion...
Warning, long explanation ahead! (Originally I posted this with code,
but the message was too long, so I'm resending it...)
There are a couple of different things to do here.
* To resize the window, use -[NSWindow setFrame:display:animate:].
* To add the extra controls, get the view that they should be inside of
(this may be your window's content view, or some other NSView or NSBox
inside of that), and add each extra view using -[NSView addSubview:].
Getting all of the other details right is a little tricky, though:
* You need to make sure that your extra controls are in the nextKeyView
loop when they are in the window, and take them out of the loop when
they aren't.
* If your window is resizeable, and the "normal" controls in it are set
up to resize with the window, their resize behavior needs to be
different while the window is automatically resizing. (I forget all of
the details...it's been a while since I handled this.)
* If your window isn't visible, don't animate the resize--it will take
time even though nothing is actually shown on screen.
The class I use is here:
http://www.snoize.com/DisclosableView.tar.gz
To see it in action, download my app MIDI Monitor:
http://www.snoize.com/MIDIMonitor/
You use it by creating your window in a nib in the normal way, with
everything set up in the configuration when the extra controls are
shown. Select the extra controls, and select Layout->Make Subviews
Of->Custom View in IB. Make the custom view be an instance of this
class (DisclosableView). Hook up a button to the -toggleDisclosure:
action of the DisclosableView.
(You will undoubtedly want to experiment with how your controls and the
disclosable view are positioned. You can also set the disclosable view
to have a non-zero height when the items in it are hidden, using
-setHiddenHeight:.)
Hope this helps. Does anyone else have an implementation of something
similar? I don't claim that mine is particularly fantastic or general or
anything, but it works for me.
--
Kurt Revis
email@hidden
_______________________________________________
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.