Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1884)

Unified Diff: content/shell/shell_mac.mm

Issue 10832221: Add keyboard shortcuts for Mac content shell. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/shell_mac.mm
diff --git a/content/shell/shell_mac.mm b/content/shell/shell_mac.mm
index f5f98a04882dfe388f04989e8e266cf6a5b44719..221758c31be46f9abdaa7b2c7893dae0ff50d4a7 100644
--- a/content/shell/shell_mac.mm
+++ b/content/shell/shell_mac.mm
@@ -99,7 +99,9 @@ void MakeShellButton(NSRect* rect,
NSString* title,
NSView* parent,
int control,
- NSView* target) {
+ NSView* target,
+ NSString* key,
+ NSUInteger modifier) {
scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:*rect]);
[button setTitle:title];
[button setBezelStyle:NSSmallSquareBezelStyle];
@@ -107,6 +109,8 @@ void MakeShellButton(NSRect* rect,
[button setTarget:target];
[button setAction:@selector(performAction:)];
[button setTag:control];
+ [button setKeyEquivalent:key];
+ [button setKeyEquivalentModifierMask:modifier];
[parent addSubview:button];
rect->origin.x += kButtonWidth;
}
@@ -201,13 +205,13 @@ void Shell::PlatformCreateWindow(int width, int height) {
kButtonWidth, kURLBarHeight);
MakeShellButton(&button_frame, @"Back", content, IDC_NAV_BACK,
- (NSView*)delegate);
+ (NSView*)delegate, @"[", NSCommandKeyMask);
MakeShellButton(&button_frame, @"Forward", content, IDC_NAV_FORWARD,
- (NSView*)delegate);
+ (NSView*)delegate, @"]", NSCommandKeyMask);
MakeShellButton(&button_frame, @"Reload", content, IDC_NAV_RELOAD,
- (NSView*)delegate);
+ (NSView*)delegate, @"r", NSCommandKeyMask);
MakeShellButton(&button_frame, @"Stop", content, IDC_NAV_STOP,
- (NSView*)delegate);
+ (NSView*)delegate, @".", NSCommandKeyMask);
button_frame.size.width =
NSWidth(initial_window_bounds) - NSMinX(button_frame);
@@ -282,8 +286,15 @@ void Shell::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
// The event handling to get this strictly right is a tangle; cheat here a bit
// by just letting the menus have a chance at it.
- if ([event.os_event type] == NSKeyDown)
+ if ([event.os_event type] == NSKeyDown) {
+ if (([event.os_event modifierFlags] & NSCommandKeyMask) &&
+ [[event.os_event characters] isEqual:@"l"]) {
+ [window_ makeFirstResponder:url_edit_view_];
+ return;
+ }
+
[[NSApp mainMenu] performKeyEquivalent:event.os_event];
+ }
}
} // namespace content
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698