Re: Adding a new menu programmatically
site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:mime-version:subject:date:references :x-mailer; bh=zcCSKqWBV+w6Rt9YwK2Yd4KBy/0azCDl5aGurrpUyFk=; b=PH4uvUi4wYVHQaqfPAdJicfHGLb5wZtKvmGR8zJq5bCUYW8dfQx/2MEX6USvjAIO3Y Rm8IhlKMIGLKMkPcSVoEkjObr+5bYm7rPkQFefxLxTkWwx7I5GOci6s0IL8eAZOwmBBU 9K/kY0MA5M1Nmllcl+jQyuiY0w7kwstWkYFxY= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type:mime-version:subject :date:references:x-mailer; b=YRQzKtjEqg+yg3zUUdfhnKHyvqv+Xpwd9WytMOrFlNDrF0SOXCxKnMi5IzsfEUQHfO VfVhaNxnWT5Gn3jlryDClmTJxzEVgIPQpaGjdcDJFQDbcP8wXOvNmX08+iBvmEZJ+ju8 s/XxLpQ4m8qZg+1X0nkfaaoJ/iRFfEhch+O04= On Sep 30, 2008, at 16:20 , Matthew Gertner 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]; Unfortunately that doesn't seem to do anything at all. I thought that the top-level menus were actually menu items on the main menu, but perhaps I am misunderstanding? NSMenu *newMenu; NSMenuItem *newItem; HTH, Jason _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.apple... This email sent to site_archiver@lists.apple.com This is from the MenuMadness example application included with Xcode and works fine for me: // Add the submenu newItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"Flashy" action:NULL keyEquivalent:@""]; newMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Flashy"]; [newItem setSubmenu:newMenu]; [newMenu release]; [[NSApp mainMenu] addItem:newItem]; [newItem release]; smime.p7s
participants (1)
-
Jason Coco