Bring Cocoa application menus up to par with the OS X Human Interface Guidelines, including supporting key equivalents.
authorSam Lantinga
Sat, 29 Sep 2012 03:42:40 -0700
changeset 6515f750d9ecae1e
parent 6514 e94c2eaaa1ab
child 6516 044ce237801a
Bring Cocoa application menus up to par with the OS X Human Interface Guidelines, including supporting key equivalents.
src/video/cocoa/SDL_cocoaevents.m
     1.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Sat Sep 29 02:50:42 2012 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Sat Sep 29 03:42:40 2012 -0700
     1.3 @@ -81,6 +81,7 @@
     1.4      NSString *appName;
     1.5      NSString *title;
     1.6      NSMenu *appleMenu;
     1.7 +    NSMenu *serviceMenu;
     1.8      NSMenu *windowMenu;
     1.9      NSMenuItem *menuItem;
    1.10      
    1.11 @@ -97,14 +98,22 @@
    1.12  
    1.13      [appleMenu addItem:[NSMenuItem separatorItem]];
    1.14  
    1.15 -    [appleMenu addItemWithTitle:@"Preferences" action:nil keyEquivalent:@""];
    1.16 +    [appleMenu addItemWithTitle:@"Preferences…" action:nil keyEquivalent:@","];
    1.17 +
    1.18 +    [appleMenu addItem:[NSMenuItem separatorItem]];
    1.19 +
    1.20 +    serviceMenu = [[NSMenu alloc] initWithTitle:@""];
    1.21 +    menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
    1.22 +    [menuItem setSubmenu:serviceMenu];
    1.23 +
    1.24 +    [NSApp setServicesMenu:serviceMenu];
    1.25  
    1.26      [appleMenu addItem:[NSMenuItem separatorItem]];
    1.27  
    1.28      title = [@"Hide " stringByAppendingString:appName];
    1.29 -    [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@/*"h"*/""];
    1.30 +    [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
    1.31  
    1.32 -    menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@/*"h"*/""];
    1.33 +    menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
    1.34      [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
    1.35  
    1.36      [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
    1.37 @@ -112,7 +121,7 @@
    1.38      [appleMenu addItem:[NSMenuItem separatorItem]];
    1.39  
    1.40      title = [@"Quit " stringByAppendingString:appName];
    1.41 -    [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@/*"q"*/""];
    1.42 +    [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
    1.43      
    1.44      /* Put menu into the menubar */
    1.45      menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
    1.46 @@ -128,11 +137,11 @@
    1.47      /* Create the window menu */
    1.48      windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
    1.49      
    1.50 -    /* "Minimize" item */
    1.51 -    menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@/*"m"*/""];
    1.52 -    [windowMenu addItem:menuItem];
    1.53 -    [menuItem release];
    1.54 +    /* Add menu items */
    1.55 +    [windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
    1.56      
    1.57 +    [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
    1.58 +
    1.59      /* Put menu into the menubar */
    1.60      menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
    1.61      [menuItem setSubmenu:windowMenu];