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

Side by Side Diff: chrome/views/accelerator.cc

Issue 28121: Do not map virtual keycodes (VK_0 - VK_9) to characters when accelerators in ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/views/accelerator.h" 5 #include "chrome/views/accelerator.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/common/l10n_util.h" 9 #include "chrome/common/l10n_util.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 string_id = IDS_F1_KEY; 45 string_id = IDS_F1_KEY;
46 break; 46 break;
47 case VK_F11: 47 case VK_F11:
48 string_id = IDS_F11_KEY; 48 string_id = IDS_F11_KEY;
49 break; 49 break;
50 } 50 }
51 51
52 std::wstring shortcut; 52 std::wstring shortcut;
53 if (!string_id) { 53 if (!string_id) {
54 // Our fallback is to try translate the key code to a regular char. 54 // Our fallback is to try translate the key code to a regular char.
55 wchar_t key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR)); 55 wchar_t key;
56 // Special-case digits. Some keyboard layouts (e.g. French)
57 // have characters other than digits assigned in an unshifted mode.
58 // For display in the menu (e.g. Ctrl-0 for the default zoom level), we
59 // still want to show digits.
60 if (key_code_ >= '0' && key_code_ <= '9')
61 key = key_code_;
62 else
63 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
56 shortcut += key; 64 shortcut += key;
57 } else { 65 } else {
58 shortcut = l10n_util::GetString(string_id); 66 shortcut = l10n_util::GetString(string_id);
59 } 67 }
60 68
61 // Checking whether the character used for the accelerator is alphanumeric. 69 // Checking whether the character used for the accelerator is alphanumeric.
62 // If it is not, then we need to adjust the string later on if the locale is 70 // If it is not, then we need to adjust the string later on if the locale is
63 // right-to-left. See below for more information of why such adjustment is 71 // right-to-left. See below for more information of why such adjustment is
64 // required. 72 // required.
65 std::wstring shortcut_rtl; 73 std::wstring shortcut_rtl;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Subtracting the size of the shortcut key and 1 for the '+' sign. 119 // Subtracting the size of the shortcut key and 1 for the '+' sign.
112 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); 120 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1);
113 shortcut.swap(shortcut_rtl); 121 shortcut.swap(shortcut_rtl);
114 } 122 }
115 123
116 return shortcut; 124 return shortcut;
117 } 125 }
118 126
119 } // namespace views 127 } // namespace views
120 128
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698