Reliable way to get application (Apple) menu?
Reliable way to get application (Apple) menu?
- Subject: Reliable way to get application (Apple) menu?
- From: Jeremy Dronfield <email@hidden>
- Date: Sat, 12 Mar 2005 13:58:51 +0000
Here's a strange omission I stumbled over when trying to remove some
items from my app's application (or, confusingly, "Apple") menu at
launch. First, I tried the obvious ploy of accessing it with:
NSMenu *appMenu = [[[NSApp mainMenu] itemWithTitle:myAppName] submenu];
but that doesn't work, so I tried outputting a description of [NSApp
mainMenu], and found that the item actually has no title:
<MenuItem: 0x34d470 , submenu: 0x342b30 (Apple)>, <<< No title!
<MenuItem: 0x343490 File, submenu: 0x341bf0 (File)>,
<MenuItem: 0x342850 Edit, submenu: 0x343840 (Edit)>,
<MenuItem: 0x3434d0 View, submenu: 0x34c710 (View)>,
So instead I've done:
NSMenu *appMenu = [[[NSApp mainMenu] itemWithTitle:@""] submenu];
which works. But I'll be stuffed if Apple changes this untitled state
in the future. NSApplication has convenience methods for returning
-windowsMenu and -servicesMenu. It also has a -setAppleMenu: method for
changing the application menu, but nothing for accessing it. Why isn't
there an -appleMenu method? Is there a reliable way of accessing this
menu which I've overlooked?
Regards,
-Jeremy
===================================
SkoobySoft, home of viJournal and Skooby Renamer
email: email@hidden or visit:
http://freespace.virgin.net/jeremy.dronfield/skoobysoft.html
===================================
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden