Read carefully through your
toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar: method. You
have copy and paste errors at the very least. A little careful code
inspection and possibly stepping through this with a debugger should
reveal your issues.

-Rob

On Wed, Mar 19, 2008 at 4:09 PM, Lincoln Green
<[EMAIL PROTECTED]> wrote:
> I have the following code in an NSObject subclass, called LGObject.
>  static NSString *NewToolbarItemIdentifier = @"New";
>  static NSString *OpenToolbarItemIdentifier = @"Open";
>  static NSString *SaveToolbarItemIdentifier = @"Save";;
>  static NSString *PrintToolbarItemIdentifier = @"Print";
>  static NSString *FormatToolbarItemIdentifier = @"Format";
>  static NSString *InfoToolbarItemIdentifier = @"Info";
>
>  - (void)awakeFromNib
>  {
>             NSToolbar *toolbar = [[NSToolbar alloc]
>  initWithIdentifier:@"LGToolbar";];
>
>      // set initial toolbar properties
>      [toolbar setAllowsUserCustomization:YES];
>      [toolbar setAutosavesConfiguration:YES];
>      [toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
>
>      // set our controller as the toolbar delegate
>      [toolbar setDelegate:self];
>
>      // attach the toolbar to our window
>      [windowOut setToolbar:toolbar];
>
>      // clean up
>      [toolbar release];
>
>  }
>
>  - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar {
>      return [NSArray arrayWithObjects:
>         NewToolbarItemIdentifier,
>          OpenToolbarItemIdentifier,
>         SaveToolbarItemIdentifier,
>         PrintToolbarItemIdentifier,
>         FormatToolbarItemIdentifier,
>         InfoToolbarItemIdentifier,
>          NSToolbarFlexibleSpaceItemIdentifier,
>          NSToolbarSpaceItemIdentifier,
>          NSToolbarSeparatorItemIdentifier, nil];
>  }
>
>  - (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar
>  {
>      return [NSArray arrayWithObjects:NewToolbarItemIdentifier,
>          NSToolbarFlexibleSpaceItemIdentifier,
>          OpenToolbarItemIdentifier, nil];
>  }
>
>  - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:
>  (NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
>  {
>      NSToolbarItem *toolbarItem = nil;
>
>      if ([itemIdentifier isEqualTo:NewToolbarItemIdentifier]) {
>          toolbarItem = [[NSToolbarItem alloc]
>  initWithItemIdentifier:itemIdentifier];
>          [toolbarItem setLabel:@"New"];
>          [toolbarItem setPaletteLabel:@"New"];
>          [toolbarItem setToolTip:@"New Document"];
>          [toolbarItem setImage:[NSImage imageNamed:@"Add.tiff"]];
>          [toolbarItem setTarget:fileOwnerOut];
>          [toolbarItem setAction:@selector(newDocument:)];
>      }
>         else if ([itemIdentifier isEqualTo:OpenToolbarItemIdentifier]) {
>          toolbarItem = [[NSToolbarItem alloc]
>  initWithItemIdentifier:itemIdentifier];
>          [toolbarItem setLabel:@"Open"];
>          [toolbarItem setPaletteLabel:@"Open"];
>          [toolbarItem setToolTip:@"Open Document"];
>          [toolbarItem setImage:[NSImage imageNamed:@"Folder.tiff"]];
>          [toolbarItem setTarget:fileOwnerOut];
>          [toolbarItem setAction:@selector(openDocument:)];
>      }
>         else if ([itemIdentifier isEqualTo:SaveToolbarItemIdentifier]) {
>          toolbarItem = [[NSToolbarItem alloc]
>  initWithItemIdentifier:itemIdentifier];
>          [toolbarItem setLabel:@"Save"];
>          [toolbarItem setPaletteLabel:@"Save"];
>          [toolbarItem setToolTip:@"Save Document"];
>          [toolbarItem setImage:[NSImage imageNamed:@"flag.tiff"]];
>          [toolbarItem setTarget:fileOwnerOut];
>          [toolbarItem setAction:@selector(saveDocument:)];
>      }
>         else if ([itemIdentifier isEqualTo:PrintToolbarItemIdentifier]) {
>          toolbarItem = [[NSToolbarItem alloc]
>  initWithItemIdentifier:itemIdentifier];
>          [toolbarItem setLabel:@"Print"];
>          [toolbarItem setPaletteLabel:@"Print"];
>          [toolbarItem setToolTip:@"Print Document"];
>          [toolbarItem setImage:[NSImage imageNamed:@"Print.png"]];
>          [toolbarItem setTarget:fileOwnerOut];
>          [toolbarItem setAction:@selector(printDocument:)];
>      }
>         else if ([itemIdentifier isEqualTo:InfoToolbarItemIdentifier]) {
>          toolbarItem = [[NSToolbarItem alloc]
>  initWithItemIdentifier:itemIdentifier];
>          [toolbarItem setLabel:@"New"];
>          [toolbarItem setPaletteLabel:@"New"];
>          [toolbarItem setToolTip:@"New Document"];
>          [toolbarItem setImage:[NSImage imageNamed:@"Add.tiff"]];
>          [toolbarItem setTarget:[infoWindowOut windowController]];
>          [toolbarItem setAction:@selector(showWindow:)];
>      }
>
>         else if ([itemIdentifier isEqualTo:FormatToolbarItemIdentifier]) {
>          toolbarItem = [[NSToolbarItem alloc]
>  initWithItemIdentifier:itemIdentifier];
>          [toolbarItem setLabel:@"Format"];
>          [toolbarItem setPaletteLabel:@"Format"];
>          [toolbarItem setToolTip:@"Format Drawer"];
>          [toolbarItem setImage:[NSImage imageNamed:@"Drawer.tiff"]];
>          [toolbarItem setTarget:formatDrawerOut];
>          [toolbarItem setAction:@selector(toggle:)];
>      }
>
>         return [toolbarItem autorelease];
>  }
>  However, the only toolbar items that work are the "Format", and
>  "Print". The "Info" item does not show up at all, and all the others
>  are disabled. fileOwnerOut is an outlet hooked up to my File's Owner
>  instance in IB. Any suggestions?

-- 
Rob Napier -- Software and Security Consulting -- http://robnapier.net
"Those who would give up essential liberty to purchase a little
temporary safety, deserve neither liberty nor safety." -- B. Franklin,
Printer
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to