• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa Drawers Example
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Drawers Example


  • Subject: Re: Cocoa Drawers Example
  • From: Tom Waters <email@hidden>
  • Date: Wed, 6 Jun 2001 14:31:57 -0700

Yeah, but I figured what he was going to ask next was how to tell when the drawer opened and closed and how to change the state of the menu item that triggered the toggle. :-)

On Wednesday, June 6, 2001, at 02:29 PM, Scott Anguish wrote:


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 :-)


References: 
 >Re: Cocoa Drawers Example (From: Scott Anguish <email@hidden>)

  • Prev by Date: Re: Cocoa Drawers Example
  • Next by Date: Re: Rhapsody Developer's Guide
  • Previous by thread: Re: Cocoa Drawers Example
  • Next by thread: Re: Cocoa Drawers Example
  • Index(es):
    • Date
    • Thread