• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Changing app menu title programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Changing app menu title programmatically
      • From: Matthew Gertner <email@hidden>
References: 
 >Changing app menu title programmatically (From: Matthew Gertner <email@hidden>)

  • Prev by Date: Re: In-loop releasing of objects does not free memory?
  • Next by Date: Re: [RESOLVED] Re: Curious about copyWithZone message from NSArrayController in "GC required" project
  • Previous by thread: Re: Changing app menu title programmatically
  • Next by thread: Re: Changing app menu title programmatically
  • Index(es):
    • Date
    • Thread