Re: Cocoa Drawers Example
Re: Cocoa Drawers Example
- Subject: Re: Cocoa Drawers Example
- From: Scott Anguish <email@hidden>
- Date: Wed, 6 Jun 2001 17:29:31 -0400
On Wednesday, June 6, 2001, at 04:49 PM, Tom Waters wrote:
There really isn't much in the way of code for drawers. You make a
window with a drawer in IB, and connect it up to your outlets. Throw
another view in the drawer and deal with it just like you would if it
was in a window.
In order to open and close it, put this in your document subclass, or
app delegate, and hook it up to buttons, menu items, and toolbar
items...
// uses IBOutlet id drawer; // hooked up in IB
- (void)toggleDrawer:(id)sender
{
if ([sender class] == [NSMenuItem class]) {
id oc = [drawer state] == NSDrawerOpenState ? @"Show" : @"Hide";
[sender setTitle: [oc stringByAppendingString: @" Drawer"]];
}
[drawer toggle: sender];
}
This isn't even required, since it is built into the drawer.. so if
you connect the button or menu to the toggle: function in the drawer
directly you can eliminate another 8 lines of code.. :-)
if you need to do this in your own code, you can just do
- (void)toggleDrawer:(id)sender
{
[drawer toggle:self];
}
Done.. but you don't even need to do that :-)