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:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=rqsiXQe7moDYh2Fq2ge+vpQrcW3JPA1VmX9Of+P8wsw=; b=B6L8qu+KZTF+T7Jplfna+CQWEFdsuiCVz+7/rAhGCQM7Y+WFc+dBrM+YUkr/eFVKVT +JtYLijm/5AjcFwf3T832dVoBdbygNG2p1h0gJDvoN+utiFdyBly1pcwt1fRJMsSv3UO 3zj9GyMHIUAIRQzm5J5nAF6QPuq/2cakBqWeQ= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=PX2iTsqJ/YrwTH9EU5Do2u+tetGazoGPSiAs2KBOFdaR1x7/DmbQRNt7snlNm0fT7r B4QzKhhonW3jd3E6pdKRkphqrU6z1m9RSH62iuyUgUTlEaHD74eARxC41hAdix0R7bv5 ocdXRzB0AfDNdvUTHpqV77Udr/jCbwvXxxq4o= On Tue, Sep 30, 2008 at 1:20 PM, Matthew Gertner <matthew.gertner@gmail.com> 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 (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
participants (1)
-
Colin Barrett