Skip navigation.
 
mlChanging app menu title programmatically
FROM : Matthew Gertner
DATE : Thu Feb 14 19:33:04 2008

Hi,

Our application lets the user create new app bundles that have their own
name, icon, etc. but which actually spawn the original application (with
the appropriate command-line parameters) using exec. I would like the
generated app bundle to display the name of that application as the
title of the application menu. But since it's spawning the original app,
it uses its title. For example, if I use the original app "Foo" to
create a new app bundle called "Bar", I'll see "Bar" on my desktop with
the right icon, etc. But when I run it, it actually runs Foo (since the
bar executable is just a script that calls "exec foo") and the title of
the app menu is still "Foo".

I can see two possible ways to fix this. One is to change something in
Bar's app bundle so that the right name is used. I tried changing
CFBundleName in Info.plist, however, and this doesn't appear to have any
effect. Whatever I try, the name from the spawned app bundle (Foo) is
always used.

I also tried changing the menu title programmatically by registering a
notification sink for NSApplicationDidFinishLaunchingNotification. I
read somewhere that I should use:

[[NSApp mainMenu] itemAtIndex:0] submenu]

...to get the application menu. When I do so, I get a menu with the
title "Apple" (rather than "Foo" which is what I expected). When I
change the title (using setTitle), the change is not reflected in the UI.

Am I way off base in taking this approach? If so, what approach would
you recommend? If not, what do I need to do to get the menu's title to
change in the UI?

Thanks in advance,
Matt

Related mailsAuthorDate
mlChanging app menu title programmatically Matthew Gertner Feb 14, 19:33
mlRe: Changing app menu title programmatically John Stiles Feb 14, 20:31
mlRe: Changing app menu title programmatically Nir Soffer Feb 15, 00:34
mlRe: Changing app menu title programmatically Matthew Gertner Feb 15, 11:31