• 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: Adding a new menu programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding a new menu programmatically


  • Subject: Re: Adding a new menu programmatically
  • From: "Colin Barrett" <email@hidden>
  • Date: Tue, 30 Sep 2008 19:35:42 -0700

On Tue, Sep 30, 2008 at 1:20 PM, Matthew Gertner
<email@hidden> wrote:
> Hi,
>
> I'm trying to add a new menu to the main menu of my application using
> Cocoa. I thought something like this would do the trick:
>
>  NSMenu* menu = [[NSMenu alloc] initWithTitle:@"foo"];
>  NSMenuItem* item = [[NSApp mainMenu] addItemWithTitle:@"foo"
>        action: nil
>        keyEquivalent: @""];
>  [item setSubmenu:menu];

You need to add that menu to the menubar. Use -[NSApplication
mainMenu] to get at the menubar and then add your menu to it.

-Colin
_______________________________________________

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

References: 
 >Adding a new menu programmatically (From: "Matthew Gertner" <email@hidden>)

  • Prev by Date: Adding a new menu programmatically
  • Next by Date: Re: Adding a new menu programmatically
  • Previous by thread: Adding a new menu programmatically
  • Next by thread: Re: Adding a new menu programmatically
  • Index(es):
    • Date
    • Thread