• 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
Cannot get toolbar to appear in window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cannot get toolbar to appear in window


  • Subject: Cannot get toolbar to appear in window
  • From: Timothy Mowlem <email@hidden>
  • Date: Wed, 25 Apr 2007 20:10:35 +0100

Hello,

I am trying to learn how to use toolbars but, despite working through Apple's example code, I cannot make the toolbar appear in the window in my simple test case. I have created a bare bones test project with a main nib containing a window with a couple of controls and the menubar. The project defines TMApplicationDelegate, a class which is set to be both the Application's delegate and the NSToolbar's delegate.

It contains the three required methods "toolbarAllowedItemIdentifiers:", "toolbarDefaultItemIdentifiers:" and "toolbar: itemForItemIdentifier: willBeInsertedIntoToolbar:"

I have set up an instance of the delegate in IB and set it to the delegate outlet of Files Owner (NSApp). When I build and run the app the window appears but without a toolbar. The log output was:

[Session started at 2007-04-24 23:31:05 +0100.]
2007-04-24 23:31:05.670 ToolbarTest[867] ### setupToolbar

I cannot see why the toolbar doesn't appear since the correct method was called. The method implmentation was:

NSLog(@"### setupToolbar");
NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"mainToolbar"];
[toolbar autorelease];
[toolbar setAutosavesConfiguration:YES];
[toolbar setAllowsUserCustomization:YES];
[toolbar setDelegate:self];
[[NSApp mainWindow] setToolbar:toolbar];


The examples I have seen use a Controller or WindowController. But I have a simple app with a single window so I am including the toolbar setup routines in the application delegate class rather than create a separate Controller. My delegate class derives implicitly from NSObject. As I understand it the awakeFromNib method is defined in an informal protocol on NSObject. So any class deriving from NSObject can implement awakeFromNib and receive the message when the main nib has loaded.

This is what the code above uses. No toolbar.

I also tried replacing awakeFromNib with the NSApplication delegate method "applicationDidFinishLaunching: (NSNotification *) aNotification"

I put the toolbar setup code in here and ran the app. Again the setupToolbar method was called, the window appeared but without a toolbar. The log output was:

[Session started at 2007-04-24 23:50:08 +0100.]
2007-04-24 23:50:08.812 ToolbarTest[916] ### applicationDidFinishLaunching
2007-04-24 23:50:08.812 ToolbarTest[916] ### setupToolbar


I have looked at the Cocoa documentation quite a lot and searched the mailing lists without any success.

Any help would be appreciated.


Thank you,

Timothy Mowlem




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Cannot get toolbar to appear in window
      • From: Steve Israelson <email@hidden>
    • Re: Cannot get toolbar to appear in window
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: Using OpenSSL with the Security framework
  • Next by Date: Re: Cannot get toolbar to appear in window
  • Previous by thread: Re: Implementing Table Selection Support for Custom Controller?
  • Next by thread: Re: Cannot get toolbar to appear in window
  • Index(es):
    • Date
    • Thread