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

Side by Side Diff: ui/base/cocoa/cocoa_event_utils.mm

Issue 152643007: mac: Create a static mapping of accelerators in the main menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@acc_list
Patch Set: Indent error. Created 6 years, 10 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
« no previous file with comments | « ui/base/cocoa/cocoa_event_utils.h ('k') | ui/events/keycodes/keyboard_code_conversion_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/base/cocoa/cocoa_event_utils.h" 5 #import "ui/base/cocoa/cocoa_event_utils.h"
6 6
7 #include "ui/base/window_open_disposition.h" 7 #include "ui/base/window_open_disposition.h"
8 #include "ui/events/event_constants.h" 8 #include "ui/events/event_constants.h"
9 9
10 namespace { 10 namespace {
(...skipping 25 matching lines...) Expand all
36 } // namespace 36 } // namespace
37 37
38 namespace ui { 38 namespace ui {
39 39
40 // Retrieves a bitsum of ui::EventFlags from NSEvent. 40 // Retrieves a bitsum of ui::EventFlags from NSEvent.
41 int EventFlagsFromNSEvent(NSEvent* event) { 41 int EventFlagsFromNSEvent(NSEvent* event) {
42 NSUInteger modifiers = [event modifierFlags]; 42 NSUInteger modifiers = [event modifierFlags];
43 return EventFlagsFromNSEventWithModifiers(event, modifiers); 43 return EventFlagsFromNSEventWithModifiers(event, modifiers);
44 } 44 }
45 45
46 int EventFlagsFromNSEventWithModifiers(NSEvent* event, NSUInteger modifiers) { 46 int EventFlagsFromModifiers(NSUInteger modifiers) {
47 int flags = 0; 47 int flags = 0;
48 flags |= (modifiers & NSAlphaShiftKeyMask) ? ui::EF_CAPS_LOCK_DOWN : 0; 48 flags |= (modifiers & NSAlphaShiftKeyMask) ? ui::EF_CAPS_LOCK_DOWN : 0;
49 flags |= (modifiers & NSShiftKeyMask) ? ui::EF_SHIFT_DOWN : 0; 49 flags |= (modifiers & NSShiftKeyMask) ? ui::EF_SHIFT_DOWN : 0;
50 flags |= (modifiers & NSControlKeyMask) ? ui::EF_CONTROL_DOWN : 0; 50 flags |= (modifiers & NSControlKeyMask) ? ui::EF_CONTROL_DOWN : 0;
51 flags |= (modifiers & NSAlternateKeyMask) ? ui::EF_ALT_DOWN : 0; 51 flags |= (modifiers & NSAlternateKeyMask) ? ui::EF_ALT_DOWN : 0;
52 flags |= (modifiers & NSCommandKeyMask) ? ui::EF_COMMAND_DOWN : 0; 52 flags |= (modifiers & NSCommandKeyMask) ? ui::EF_COMMAND_DOWN : 0;
53 return flags;
54 }
55
56 int EventFlagsFromNSEventWithModifiers(NSEvent* event, NSUInteger modifiers) {
57 int flags = EventFlagsFromModifiers(modifiers);
53 flags |= isLeftButtonEvent(event) ? ui::EF_LEFT_MOUSE_BUTTON : 0; 58 flags |= isLeftButtonEvent(event) ? ui::EF_LEFT_MOUSE_BUTTON : 0;
54 flags |= isRightButtonEvent(event) ? ui::EF_RIGHT_MOUSE_BUTTON : 0; 59 flags |= isRightButtonEvent(event) ? ui::EF_RIGHT_MOUSE_BUTTON : 0;
55 flags |= isMiddleButtonEvent(event) ? ui::EF_MIDDLE_MOUSE_BUTTON : 0; 60 flags |= isMiddleButtonEvent(event) ? ui::EF_MIDDLE_MOUSE_BUTTON : 0;
56 return flags; 61 return flags;
57 } 62 }
58 63
59 WindowOpenDisposition WindowOpenDispositionFromNSEvent(NSEvent* event) { 64 WindowOpenDisposition WindowOpenDispositionFromNSEvent(NSEvent* event) {
60 NSUInteger modifiers = [event modifierFlags]; 65 NSUInteger modifiers = [event modifierFlags];
61 return WindowOpenDispositionFromNSEventWithFlags(event, modifiers); 66 return WindowOpenDispositionFromNSEventWithFlags(event, modifiers);
62 } 67 }
63 68
64 WindowOpenDisposition WindowOpenDispositionFromNSEventWithFlags( 69 WindowOpenDisposition WindowOpenDispositionFromNSEventWithFlags(
65 NSEvent* event, NSUInteger modifiers) { 70 NSEvent* event, NSUInteger modifiers) {
66 int event_flags = EventFlagsFromNSEventWithModifiers(event, modifiers); 71 int event_flags = EventFlagsFromNSEventWithModifiers(event, modifiers);
67 return ui::DispositionFromEventFlags(event_flags); 72 return ui::DispositionFromEventFlags(event_flags);
68 } 73 }
69 74
70 } // namespace ui 75 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/cocoa/cocoa_event_utils.h ('k') | ui/events/keycodes/keyboard_code_conversion_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698