Any way to re-add a menu in IB?

Shookster

Registered
My application doesn't really need any menu options such as File, Edit, Format, etc, due to the nature of it, so I removed the NSMenuBar class from the Instances tab in IB 2, with the intent of adding it back later on should the need for a menu arise.

What I did not realize is that removing the menu would remove the app's ability to close. I now want to add it back but I can't see an option for it, only right-click menus. I read on the internet that the only way is to create a brand new NIB file and start from scratch. I tried this but I could not paste the controls I had already added into the new dialog. Is this really my only option? Seems a little silly to me.
 
You mean you can't instantiate an NSMenu?

Thanks for your reply. I can instantiate NSMenu, but when I drag items onto it, they are displayed vertically like a right-click menu and not horizontally like the menu bar. If I select the menu and go to Attributes, there are several radio buttons for special menus, including one for Main Menu (I suspect this is what I am looking for) but these are all disabled.
 
Although I'm using the dev tools under Leopard some things are different, but you brought up something that I may want to do try myself, dynamically add and remove menu items from the menu bar based on how the user navigates.
Interface builder has moved things around, so it doesn't work the same. I'll let you know what happens.
 
In IB3 when I delete the original NSMenu from MainMenu.nib and I add a new NSMenu from the object library it gives me a stripped down menubar with no menu items other than quit application. You don't get this in IB2? I can't recall, but I thought it worked the same before as well.
 
Those disabled "Special Menu" buttons seem to be a bug, they're always disabled (IB 2 anyway). But here's a workaround that worked for me (IB 2.5.4, Xcode 2.4.1):

(1) Open existing nib file in IB

(2) Fire up Xcode if it's not already running

(3) Create a New Cocoa Application Project in XC, calling it whatever you want, "temp" or something. Double-click the MainMenu.nib to open it in IB

(4) in IB, option-drag the MainMenu icon from the new project to your existing one. (Or Apple-C to copy, and Apple-V to paste). The familiar main menu "preview window" should appear instantly (NewApplication File Edit.... etc.)

(5) Save modified nib file.

(6) Heap praise, fame and free stuff on macbri ;)
 
I don't think he wants a new NSmenu, just the ability to close the app with no other items on the menu at all which he should be able to do with just an NSMenu that has the option to quit.
If it's a bug, rather than create a new project from Xcode he can just create a new mainmenu.nib in IB and drag the new NSMenu to the current project's mainmenu.nib.
 
Back
Top