How to rebuild main menu in IB - xcode

I accidentally deleted the Main Menu menu from IB and now I have a hard time to reconstruct it. I am using Xcode 4.0. Is there anyway to recreate that?

You mean main menu from the menu bar for a mac software ?
If yes, you can simply drag'n drop an NSMenuItem from the IB inspector to your menu bar.
PS : I'm not sure to have understood your question ...

Related

macOS main menu sub items don't show

I'm using storyboard to create a macOS app.
For some reason, when running the app, the sub-menu item doesn't show up at all.
The item is enabled and hooked to the first responder just like the original demo items.
Did you drag one of the special menus by mistake? The Clear Menu item makes me wonder if the menu started life as a Recent Items menu and perhaps the change didn't take. You can tell by opening your storyboard as source code and checking for the systemMenu attribute on your Scale menu:
<menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="...">

Set NSMenu as NSWindow's main menu from the NIB?

I've got two menus in my app, one will be attached to NSStatusBar and another will be app's main menu.
Is there a way to set one of the NSMenu's as the main one right from the Nib? I'm looking at another project's nib and I see the menu actually defined in the nib, while in my nib it's not showing up correctly.
Right now my app has no menu at all.
This is what my nib looks like:
How I want it to look like:
In xibs, at least in Xcode 4, the main menu is no longer an outlet of the application but rather a nature that a top-level menu object either has or doesn't have. The main menu in a main menu nib created by Xcode has that nature; a menu you create yourself does not.
As of Xcode 4.2.1, there is no way to create a menu from scratch in an existing nib and appoint it as the main menu. You must create a nib with the main menu already in it using the appropriate file template.

How can I get to the menu bar in my app in interface builder

XCode works in mysterious ways (at least to me).
I simply want to create a Preference pane in my app. When I run my app, the stock menu bar comes up (Apple, MyApp, File, Edit...) and the "Preferences" menu item is grayed out. It makes sense since I haven't started playing with it.
How on earth do I add/remove/activate/inactivate menu items? I'm not talking about adding anything new, simply using what should be there.
Thanks in advance.
NSMenu has "Auto Enable Items" enabled by default. That means if the menu item does not have it's action message hooked up, it will appear grayed out. So in your case, you would simply set the Preferences menu item's "Sent Action" to whatever action shows your preferences window. This can be hooked to some sort of showPreferencesWindow: method of your AppDelegate, or directly to the showWindow: method of a window controller.
To dynamically enable/disable menu items the best way is to implement the NSUserInterfaceItemValidation protocol which is excellently documented here
Edit: Your app's menu bar items live in the MainMenu.xib file. The menu bar appears as a "Main Menu" object on the left hand side (if you're using Xcode 4) Simply click on the items to modify them, and you can Ctrl+drag connections to and from them like any UI object.

update statusbar menu on click mac os x cocoa

I've been playing around with a statusbar menu app and what I'd like it to do is to update the content of the menu when it is clicked. I've been able to get everything working on the awakefromnib function and it works as expected. Now i just want to update the menu everytime I click on the status bar. This surely can be done, since it's done in the dropbox statusbar menu and many of the native app statusbar menus. I'm not able to associate a action directly with the click of the menu and I don't want to leave a loop running in the background cause I don't really see a need for it. Any ideas? An alternative would be to have an action associated to a menu item which does not cause the menu to get hidden again. Any help would be welcome.
Just set a delegate for your menu, and implement the -(void)menuWillOpen:(NSMenu *)menu method.

How do I get a textbox in an NSMenu?

I'm pretty sure i've seen this somewhere (not counting the help menu), and I feel like you could just drag one in under ib in leopard. Not that it matters, but it will either go into a dock menu or a service. Thanks
Try setting an NSTextField as the view of an NSMenuItem.
You can do this in IB by dragging the text field into the nib as a top-level object and setting the menu item's view outlet to point to the field.
Tricky thing you may need to solve in your app: In the IB simulator, at least, pressing return/enter did not dismiss the menu.

Resources