Re: Application main menu title behavior change in 10.6
Re: Application main menu title behavior change in 10.6
- Subject: Re: Application main menu title behavior change in 10.6
- From: Peter Ammon <email@hidden>
- Date: Fri, 4 Sep 2009 19:03:47 -0700
On Sep 4, 2009, at 11:31 AM, Jim Turner wrote:
Hi all,
I have an application (QuicKeys) that allows the user to define menu
selection as an action. In our latest version and under Leopard, we
present UI that replaces the main menu bar of our app with the menu
bar of the target app (via setMainMenu:) so that we can correctly
retrieve which menu item the user selected. Works like a champ, even
under Snow Leopard, save for one problem. Under 10.6, the application
name is always "QuicKeys", not "Finder" or whatever the target
application name would be. This is causing confusion with our users as
while the menu is really the target app's menu, it has the wrong
application name.
Reading through the release notes for AppKit on 10.6, I found that
there's been a change to how the main menu bar displays the
application's name. Specifically, under the "NSApplication
application menu item title" header, it states "... the application
menu always reflects the application name." This appears to be what's
causing the issue and I'm curious if anyone knows of a work-around?
Hi Jim,
First let me thank you for checking the release notes. However, that
particular issue is unrelated, confusingly enough.
Here's what's going on. The first menu item in the main menu (or more
precisely, its submenu) is magic, in that when it becomes the first
item, its title is ignored and instead the application name is used.
This is why you do not have to update your MainMenu.nib every time you
change your application name. In Leopard, there was a bug that caused
this to be applied inconsistently. It sounds like your application
was benefiting from this bug.
You can change the title of the application menu, after you set the
main menu, like so:
[[[[NSApp mainMenu] itemAtIndex:0] submenu] setTitle:@"New Title"]
Hope this helps,
-Peter
_______________________________________________
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