0

I'm trying to make selectable NSToolbarItems. I've connected everything correctly in IB, but toolbarSelectableItemIdentifiers: is not working. It doesn't get called. The delegate is the File's Owner (subclass of NSWindowController), and the toolbar is in a sheet. Here's my code:

// TOOLBAR DLGT
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar {
  NSLog(@"Foo");
  NSMutableArray *arr = [[NSMutableArray alloc] init];
  for (NSToolbarItem *item in [toolbar items]) {
    [arr addObject:[item itemIdentifier]];
  }
  return [arr autorelease];
}

Screenshot:
screenshot

Can you help me please?


No, I don't want to use BWToolkit.

Community
  • 1
  • 1
  • 2
    As an aside, unless you're planning to add a condition inside that loop later, you can replace the whole loop and mutable array with `return [[toolbar items] valueForKey:@"itemIdentifier"];`. NSArray implements `valueForKey:` by returning an array of every contained object's value for the key. – Peter Hosey Nov 15 '10 at 15:19

1 Answers1

0

Are you positive the toolbar's delegate outlet points to the class (or instance thereof) you think it does? Are any other NSToolbar delegate methods called there (easy enough to test)?

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135