• 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
NSToolbar help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSToolbar help


  • Subject: NSToolbar help
  • From: email@hidden
  • Date: Sun, 19 Dec 2010 19:20:36 +0000

I'm trying to add an NSToolbar to an existing application. I need compatibility with 10.4, so I'm creating the toolbar programmatically, initializing and configuring the toolbar in my -init. On launch, the toolbar does not appear and none of its delegate methods are called even though I setDelegate:self in -init. If I remove any of the delegate methods, I get an error in the console:

2010-12-19 13:13:21.415 ToolbarTest[16973:903] ERROR: invalid delegate <ToolbarTest: 0x422f30> (does not implement all required methods), and so can not be used!

This output actually came from a bare bones test application I created in an attempt to isolate the problem. Here is my code:
mainWindow is an NSWindow instance setup as an IBOutlet


@implementation ToolbarTest

-(id)init{

if(self = [super init]){

toolBar = [[[NSToolbar alloc] initWithIdentifier:@"MainToolbar"] autorelease];
[toolBar setAllowsUserCustomization:YES];
[toolBar setAutosavesConfiguration:YES];
[toolBar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
[toolBar setDelegate:self];


[mainWindow setToolbar:toolBar];

NSLog(@"Init called");
}
return self;


} - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar{

return [NSArray arrayWithObjects:NSToolbarPrintItemIdentifier,
NSToolbarShowColorsItemIdentifier,
NSToolbarShowFontsItemIdentifier,
NSToolbarCustomizeToolbarItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarSpaceItemIdentifier,
NSToolbarSeparatorItemIdentifier, nil];

}

//- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag{
//
// return nil;
//}



- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar{

return nil;
}


- (void)toolbarDidRemoveItem:(NSNotification *)notification{ return; }

- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar{
return nil;
}

- (void)toolbarWillAddItem:(NSNotification *)notification{
return;
}

@end

The application into which I'd like to add the toolbar has an NSTableView as well. Since the toolbar delegates aren't being called but the tableview's are, I added this to one of the tableview delegate methods just see what was going on with the toolbar:


- (int)numberOfRowsInTableView:(NSTableView *)aTableView{

[toolBar setVisible:YES];
BOOL cansee;
cansee = [toolBar isVisible]; // Returns NO

return 5;
}
Anyone have any ideas what's going on? Oh and I'm using Xcode 3.1.4 on Intel under 10.6
_______________________________________________


Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSToolbar help
      • From: Knut Lorenzen <email@hidden>
  • Prev by Date: metadata to propertyList
  • Next by Date: Re: NSToolbar help
  • Previous by thread: metadata to propertyList
  • Next by thread: Re: NSToolbar help
  • Index(es):
    • Date
    • Thread