Commit ee4346f6 authored by shouqun.liu@intel.com's avatar shouqun.liu@intel.com

Add keyboard shortcuts for Mac content shell.

Support navigation with keyboard shortcuts as other platform(GTK).

BUG=90445
TEST=


Review URL: https://chromiumcodereview.appspot.com/10832221

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150804 0039d316-1c4b-4281-b951-d872f2087c98
parent 0874f3cb
...@@ -99,7 +99,9 @@ void MakeShellButton(NSRect* rect, ...@@ -99,7 +99,9 @@ void MakeShellButton(NSRect* rect,
NSString* title, NSString* title,
NSView* parent, NSView* parent,
int control, int control,
NSView* target) { NSView* target,
NSString* key,
NSUInteger modifier) {
scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:*rect]); scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:*rect]);
[button setTitle:title]; [button setTitle:title];
[button setBezelStyle:NSSmallSquareBezelStyle]; [button setBezelStyle:NSSmallSquareBezelStyle];
...@@ -107,6 +109,8 @@ void MakeShellButton(NSRect* rect, ...@@ -107,6 +109,8 @@ void MakeShellButton(NSRect* rect,
[button setTarget:target]; [button setTarget:target];
[button setAction:@selector(performAction:)]; [button setAction:@selector(performAction:)];
[button setTag:control]; [button setTag:control];
[button setKeyEquivalent:key];
[button setKeyEquivalentModifierMask:modifier];
[parent addSubview:button]; [parent addSubview:button];
rect->origin.x += kButtonWidth; rect->origin.x += kButtonWidth;
} }
...@@ -201,13 +205,13 @@ void Shell::PlatformCreateWindow(int width, int height) { ...@@ -201,13 +205,13 @@ void Shell::PlatformCreateWindow(int width, int height) {
kButtonWidth, kURLBarHeight); kButtonWidth, kURLBarHeight);
MakeShellButton(&button_frame, @"Back", content, IDC_NAV_BACK, MakeShellButton(&button_frame, @"Back", content, IDC_NAV_BACK,
(NSView*)delegate); (NSView*)delegate, @"[", NSCommandKeyMask);
MakeShellButton(&button_frame, @"Forward", content, IDC_NAV_FORWARD, MakeShellButton(&button_frame, @"Forward", content, IDC_NAV_FORWARD,
(NSView*)delegate); (NSView*)delegate, @"]", NSCommandKeyMask);
MakeShellButton(&button_frame, @"Reload", content, IDC_NAV_RELOAD, MakeShellButton(&button_frame, @"Reload", content, IDC_NAV_RELOAD,
(NSView*)delegate); (NSView*)delegate, @"r", NSCommandKeyMask);
MakeShellButton(&button_frame, @"Stop", content, IDC_NAV_STOP, MakeShellButton(&button_frame, @"Stop", content, IDC_NAV_STOP,
(NSView*)delegate); (NSView*)delegate, @".", NSCommandKeyMask);
button_frame.size.width = button_frame.size.width =
NSWidth(initial_window_bounds) - NSMinX(button_frame); NSWidth(initial_window_bounds) - NSMinX(button_frame);
...@@ -283,8 +287,15 @@ void Shell::HandleKeyboardEvent(WebContents* source, ...@@ -283,8 +287,15 @@ void Shell::HandleKeyboardEvent(WebContents* source,
// The event handling to get this strictly right is a tangle; cheat here a bit // 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. // 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]; [[NSApp mainMenu] performKeyEquivalent:event.os_event];
}
} }
} // namespace content } // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment