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

Side by Side Diff: chrome/browser/cocoa/browser_window_impl.mm

Issue 149325: Add facitility for Global Keyboard shortcuts. (Closed)
Patch Set: Created 11 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/browser/cocoa/browser_window_impl.h"
6
7 #import "chrome/browser/cocoa/browser_window_controller.h"
8 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
9
10 @implementation ChromeBrowserWindowImpl
11
12 - (BOOL)performKeyEquivalent:(NSEvent *)event {
pink (ping after 24hrs) 2009/07/08 13:48:17 * goes with the type, no space.
13
pink (ping after 24hrs) 2009/07/08 13:48:17 omit blank line
14 // Extract info from event.
15 NSUInteger modifers = [event modifierFlags];
16 bool cmd_key = modifers & NSCommandKeyMask;
pink (ping after 24hrs) 2009/07/08 13:48:17 use obj-c naming in obj-c code, eg |cmdKey|
pink (ping after 24hrs) 2009/07/08 13:48:17 make these const? *shrug* just a thought.
17 bool shift_key = modifers & NSShiftKeyMask;
18 bool cntrl_key = modifers & NSControlKeyMask;
19 int keyCode = [event keyCode];
20
21 int cmd_num = CommandForKeyboardShortcut(cmd_key, shift_key, cntrl_key,
22 keyCode);
23
24 BrowserWindowController* controller =
25 (BrowserWindowController*)[self delegate];
26 // A bit of sanity.
27 DCHECK([controller isKindOfClass:[BrowserWindowController class]]);
28 DCHECK([controller respondsToSelector:@selector(executeCommand:)]);
29
30 if (cmd_num != -1) {
31 [controller executeCommand:cmd_num];
32 return YES;
33 }
34
35 return [super performKeyEquivalent:event];
36 }
37
38 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698