Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Bring Cocoa application menus up to par with the OS X Human Interface…
… Guidelines, including supporting key equivalents.
  • Loading branch information
slouken committed Sep 29, 2012
1 parent 64048de commit ea73f3a
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/video/cocoa/SDL_cocoaevents.m
Expand Up @@ -81,6 +81,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam
NSString *appName;
NSString *title;
NSMenu *appleMenu;
NSMenu *serviceMenu;
NSMenu *windowMenu;
NSMenuItem *menuItem;

Expand All @@ -97,22 +98,30 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam

[appleMenu addItem:[NSMenuItem separatorItem]];

[appleMenu addItemWithTitle:@"Preferences" action:nil keyEquivalent:@""];
[appleMenu addItemWithTitle:@"Preferences…" action:nil keyEquivalent:@","];

[appleMenu addItem:[NSMenuItem separatorItem]];

serviceMenu = [[NSMenu alloc] initWithTitle:@""];
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
[menuItem setSubmenu:serviceMenu];

[NSApp setServicesMenu:serviceMenu];

[appleMenu addItem:[NSMenuItem separatorItem]];

title = [@"Hide " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@/*"h"*/""];
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];

menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@/*"h"*/""];
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];

[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];

[appleMenu addItem:[NSMenuItem separatorItem]];

title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@/*"q"*/""];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];

/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
Expand All @@ -128,11 +137,11 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam
/* Create the window menu */
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];

/* "Minimize" item */
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@/*"m"*/""];
[windowMenu addItem:menuItem];
[menuItem release];
/* Add menu items */
[windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];

[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];

/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
[menuItem setSubmenu:windowMenu];
Expand Down

0 comments on commit ea73f3a

Please sign in to comment.