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

Side by Side Diff: ui/events/keycodes/keyboard_code_conversion_mac.mm

Issue 782673002: MacViews: tryjobs for toolkit_views=1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: latest crrev/901823002 Created 5 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/ime/text_input_client.h ('k') | ui/views/cocoa/bridged_content_view.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/events/keycodes/keyboard_code_conversion_mac.h" 5 #import "ui/events/keycodes/keyboard_code_conversion_mac.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #import <Carbon/Carbon.h> 9 #import <Carbon/Carbon.h>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 { VKEY_END /* 0x23 */, kVK_End, NSEndFunctionKey }, 58 { VKEY_END /* 0x23 */, kVK_End, NSEndFunctionKey },
59 { VKEY_HOME /* 0x24 */, kVK_Home, NSHomeFunctionKey }, 59 { VKEY_HOME /* 0x24 */, kVK_Home, NSHomeFunctionKey },
60 { VKEY_LEFT /* 0x25 */, kVK_LeftArrow, NSLeftArrowFunctionKey }, 60 { VKEY_LEFT /* 0x25 */, kVK_LeftArrow, NSLeftArrowFunctionKey },
61 { VKEY_UP /* 0x26 */, kVK_UpArrow, NSUpArrowFunctionKey }, 61 { VKEY_UP /* 0x26 */, kVK_UpArrow, NSUpArrowFunctionKey },
62 { VKEY_RIGHT /* 0x27 */, kVK_RightArrow, NSRightArrowFunctionKey }, 62 { VKEY_RIGHT /* 0x27 */, kVK_RightArrow, NSRightArrowFunctionKey },
63 { VKEY_DOWN /* 0x28 */, kVK_DownArrow, NSDownArrowFunctionKey }, 63 { VKEY_DOWN /* 0x28 */, kVK_DownArrow, NSDownArrowFunctionKey },
64 { VKEY_SELECT /* 0x29 */, -1, 0 }, 64 { VKEY_SELECT /* 0x29 */, -1, 0 },
65 { VKEY_PRINT /* 0x2A */, -1, NSPrintFunctionKey }, 65 { VKEY_PRINT /* 0x2A */, -1, NSPrintFunctionKey },
66 { VKEY_EXECUTE /* 0x2B */, -1, NSExecuteFunctionKey }, 66 { VKEY_EXECUTE /* 0x2B */, -1, NSExecuteFunctionKey },
67 { VKEY_SNAPSHOT /* 0x2C */, -1, NSPrintScreenFunctionKey }, 67 { VKEY_SNAPSHOT /* 0x2C */, -1, NSPrintScreenFunctionKey },
68 { VKEY_INSERT /* 0x2D */, -1, NSInsertFunctionKey }, 68 { VKEY_INSERT /* 0x2D */, kVK_Help, NSInsertFunctionKey },
69 { VKEY_DELETE /* 0x2E */, kVK_ForwardDelete, NSDeleteFunctionKey }, 69 { VKEY_DELETE /* 0x2E */, kVK_ForwardDelete, NSDeleteFunctionKey },
70 { VKEY_HELP /* 0x2F */, kVK_Help, kHelpCharCode }, 70 { VKEY_HELP /* 0x2F */, kVK_Help, kHelpCharCode },
71 { VKEY_0 /* 0x30 */, kVK_ANSI_0, '0' }, 71 { VKEY_0 /* 0x30 */, kVK_ANSI_0, '0' },
72 { VKEY_1 /* 0x31 */, kVK_ANSI_1, '1' }, 72 { VKEY_1 /* 0x31 */, kVK_ANSI_1, '1' },
73 { VKEY_2 /* 0x32 */, kVK_ANSI_2, '2' }, 73 { VKEY_2 /* 0x32 */, kVK_ANSI_2, '2' },
74 { VKEY_3 /* 0x33 */, kVK_ANSI_3, '3' }, 74 { VKEY_3 /* 0x33 */, kVK_ANSI_3, '3' },
75 { VKEY_4 /* 0x34 */, kVK_ANSI_4, '4' }, 75 { VKEY_4 /* 0x34 */, kVK_ANSI_4, '4' },
76 { VKEY_5 /* 0x35 */, kVK_ANSI_5, '5' }, 76 { VKEY_5 /* 0x35 */, kVK_ANSI_5, '5' },
77 { VKEY_6 /* 0x36 */, kVK_ANSI_6, '6' }, 77 { VKEY_6 /* 0x36 */, kVK_ANSI_6, '6' },
78 { VKEY_7 /* 0x37 */, kVK_ANSI_7, '7' }, 78 { VKEY_7 /* 0x37 */, kVK_ANSI_7, '7' },
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 int macKeycode = ptr->macKeycode; 468 int macKeycode = ptr->macKeycode;
469 if (keyboard_character) 469 if (keyboard_character)
470 *keyboard_character = ptr->characterIgnoringAllModifiers; 470 *keyboard_character = ptr->characterIgnoringAllModifiers;
471 471
472 if (!us_keyboard_shifted_character) 472 if (!us_keyboard_shifted_character)
473 return macKeycode; 473 return macKeycode;
474 474
475 *us_keyboard_shifted_character = ptr->characterIgnoringAllModifiers; 475 *us_keyboard_shifted_character = ptr->characterIgnoringAllModifiers;
476 476
477 // Fill in |us_keyboard_shifted_character| according to flags. 477 // Fill in |us_keyboard_shifted_character| according to flags.
478 if (flags & NSShiftKeyMask) { 478 if (keycode >= VKEY_A && keycode <= VKEY_Z) {
479 // Letter keys need to consider caps lock.
480 bool shift_pressed = (flags & NSShiftKeyMask) != 0;
481 bool caps_pressed = (flags & NSAlphaShiftKeyMask) != 0;
482 if (shift_pressed != caps_pressed)
483 *us_keyboard_shifted_character = 'A' + (keycode - VKEY_A);
484
485 } else if (flags & NSShiftKeyMask) {
479 if (keycode >= VKEY_0 && keycode <= VKEY_9) { 486 if (keycode >= VKEY_0 && keycode <= VKEY_9) {
480 *us_keyboard_shifted_character = 487 *us_keyboard_shifted_character =
481 kShiftCharsForNumberKeys[keycode - VKEY_0]; 488 kShiftCharsForNumberKeys[keycode - VKEY_0];
482 } else if (keycode >= VKEY_A && keycode <= VKEY_Z) { 489
483 *us_keyboard_shifted_character = 'A' + (keycode - VKEY_A);
484 } else { 490 } else {
485 switch (macKeycode) { 491 switch (macKeycode) {
486 case kVK_ANSI_Grave: 492 case kVK_ANSI_Grave:
487 *us_keyboard_shifted_character = '~'; 493 *us_keyboard_shifted_character = '~';
488 break; 494 break;
489 case kVK_ANSI_Minus: 495 case kVK_ANSI_Minus:
490 *us_keyboard_shifted_character = '_'; 496 *us_keyboard_shifted_character = '_';
491 break; 497 break;
492 case kVK_ANSI_Equal: 498 case kVK_ANSI_Equal:
493 *us_keyboard_shifted_character = '+'; 499 *us_keyboard_shifted_character = '+';
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 return code; 549 return code;
544 } 550 }
545 return KeyboardCodeFromKeyCode([event keyCode]); 551 return KeyboardCodeFromKeyCode([event keyCode]);
546 } 552 }
547 553
548 DomCode CodeFromNSEvent(NSEvent* event) { 554 DomCode CodeFromNSEvent(NSEvent* event) {
549 return ui::KeycodeConverter::NativeKeycodeToDomCode([event keyCode]); 555 return ui::KeycodeConverter::NativeKeycodeToDomCode([event keyCode]);
550 } 556 }
551 557
552 } // namespace ui 558 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/text_input_client.h ('k') | ui/views/cocoa/bridged_content_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698