• 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: Strange behaviour with Application menu.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange behaviour with Application menu.


  • Subject: Re: Strange behaviour with Application menu.
  • From: Sherm Pendley <email@hidden>
  • Date: Mon, 3 Jul 2006 00:36:45 -0400

On Jul 3, 2006, at 12:23 AM, RameshPVK wrote:

How to add application menu to the main menu through code. When i try to do that in code , i am getting an extra menu item with application name .

This is from a project template included with SDL. As the comment says, it's very odd. I have tested this code and verified that it works though, in a number of different apps and OS versions.


/* An internal Apple class used to setup Apple menus */
@interface NSAppleMenuController:NSObject {}
- (void)controlMenu:(NSMenu *)aMenu;
@end

void setupAppleMenu(void)
{
    /* warning: this code is very odd */
    NSAppleMenuController *appleMenuController;
    NSMenu *appleMenu;
    NSMenuItem *appleMenuItem;

appleMenuController = [[NSAppleMenuController alloc] init];
appleMenu = [[NSMenu alloc] initWithTitle:@""];
appleMenuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];


    [appleMenuItem setSubmenu:appleMenu];

/* yes, we do need to add it and then remove it --
if you don't add it, it doesn't get displayed
if you don't remove it, you have an extra, titleless item in the menubar
when you remove it, it appears to stick around
very, very odd */
[[NSApp mainMenu] addItem:appleMenuItem];
[appleMenuController controlMenu:appleMenu];
[[NSApp mainMenu] removeItem:appleMenuItem];
[appleMenu release];
[appleMenuItem release];
}


sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Strange behaviour with Application menu. (From: RameshPVK <email@hidden>)

  • Prev by Date: Strange behaviour with Application menu.
  • Next by Date: Information Regarding LoginWindows Process
  • Previous by thread: Strange behaviour with Application menu.
  • Next by thread: Information Regarding LoginWindows Process
  • Index(es):
    • Date
    • Thread