Re: Changing app menu title programmatically
Re: Changing app menu title programmatically
- Subject: Re: Changing app menu title programmatically
- From: Nir Soffer <email@hidden>
- Date: Fri, 15 Feb 2008 01:34:02 +0200
On Feb 14, 2008, at 20:33, Matthew Gertner wrote:
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.
This will not work because Foo is using its own bundle keys, not Bars.
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.
It seems that NSApplication is working hard to keep a standard
application menu item available, and you can not edit this menu item.
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?
I would change the solution to copy the application code to the new
application instead of the exec ugly hack. To prevent upgrade issues,
use minimal code that you will never change and keep all the real
code in a shared framework.
Best Regards,
Nir Soffer
_______________________________________________
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