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

Side by Side Diff: chrome/browser/ui/cocoa/nsmenuitem_additions.mm

Issue 5576002: Fix BrowserKeyEventsTest.ReservedAccelerators on Mac 10.6 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comment. Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" 5 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h"
6 6
7 #include <Carbon/Carbon.h> 7 #include <Carbon/Carbon.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 @implementation NSMenuItem(ChromeAdditions) 11 @implementation NSMenuItem(ChromeAdditions)
12 12
13 - (BOOL)cr_firesForKeyEvent:(NSEvent*)event { 13 - (BOOL)cr_firesForKeyEvent:(NSEvent*)event {
Nico 2010/12/04 20:25:15 You can then implement this function as … { if
James Su 2010/12/06 18:37:28 Done.
14 DCHECK([event type] == NSKeyDown); 14 DCHECK([event type] == NSKeyDown);
15 if (![self isEnabled])
16 return NO;
17
18 // In System Preferences->Keyboard->Keyboard Shortcuts, it is possible to add 15 // In System Preferences->Keyboard->Keyboard Shortcuts, it is possible to add
19 // arbitrary keyboard shortcuts to applications. It is not documented how this 16 // arbitrary keyboard shortcuts to applications. It is not documented how this
20 // works in detail, but |NSMenuItem| has a method |userKeyEquivalent| that 17 // works in detail, but |NSMenuItem| has a method |userKeyEquivalent| that
21 // sounds related. 18 // sounds related.
22 // However, it looks like |userKeyEquivalent| is equal to |keyEquivalent| when 19 // However, it looks like |userKeyEquivalent| is equal to |keyEquivalent| when
23 // a user shortcut is set in system preferences, i.e. Cocoa automatically 20 // a user shortcut is set in system preferences, i.e. Cocoa automatically
24 // sets/overwrites |keyEquivalent| as well. Hence, this method can ignore 21 // sets/overwrites |keyEquivalent| as well. Hence, this method can ignore
25 // |userKeyEquivalent| and check |keyEquivalent| only. 22 // |userKeyEquivalent| and check |keyEquivalent| only.
26 23
27 // Menu item key equivalents are nearly all stored without modifiers. The 24 // Menu item key equivalents are nearly all stored without modifiers. The
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 eventModifiers &= NSCommandKeyMask | 91 eventModifiers &= NSCommandKeyMask |
95 NSControlKeyMask | 92 NSControlKeyMask |
96 NSAlternateKeyMask | 93 NSAlternateKeyMask |
97 NSShiftKeyMask; 94 NSShiftKeyMask;
98 95
99 return [eventString isEqualToString:[self keyEquivalent]] 96 return [eventString isEqualToString:[self keyEquivalent]]
100 && eventModifiers == [self keyEquivalentModifierMask]; 97 && eventModifiers == [self keyEquivalentModifierMask];
101 } 98 }
102 99
103 @end 100 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698