summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-26 17:40:54 +0000
committerjungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-26 17:40:54 +0000
commitdddb3f5497326cb18f519bbbc4b79a8a5cbc53c9 (patch)
tree63df0057f98882be882c368e31630f42dffaf411
parent22b3c04fa21190d7e67fb6f75b161bc551cd4148 (diff)
downloadchromium_src-dddb3f5497326cb18f519bbbc4b79a8a5cbc53c9.zip
chromium_src-dddb3f5497326cb18f519bbbc4b79a8a5cbc53c9.tar.gz
chromium_src-dddb3f5497326cb18f519bbbc4b79a8a5cbc53c9.tar.bz2
Do not map virtual keycodes (VK_0 - VK_9) to characters when accelerators in the UI.
If we do that, the result is the layout-dependent. For instance, in fr-FR layout, we get 'a with grave' in place of '0' for Ctrl+0 (normal in Zoom menu). Besides, in Slovak lazout, we get 'e with accent' This CL does not affect the actual behavior of accelerators (see issue 8043 for that), but only change the way they're displayed in the menu (even without this CL, ctrl-0 works fine in fr-FR AZERY layout and Slovak layout). BUG=7444 TEST=Change your kbd layout to French Azery and see what key is shown next to 'Normal' in Page-Zoom menu. It should be 'Ctrl+0'. Review URL: http://codereview.chromium.org/28121 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10476 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/views/accelerator.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/chrome/views/accelerator.cc b/chrome/views/accelerator.cc
index 4a94857..b86133f 100644
--- a/chrome/views/accelerator.cc
+++ b/chrome/views/accelerator.cc
@@ -53,8 +53,17 @@ std::wstring Accelerator::GetShortcutText() const {
std::wstring shortcut;
if (!string_id) {
- // Our fallback is to try translate the key code to a regular char.
- wchar_t key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
+ // Our fallback is to try translate the key code to a regular character
+ // unless it is one of digits (VK_0 to VK_9). Some keyboard
+ // layouts have characters other than digits assigned in
+ // an unshifted mode (e.g. French AZERY layout has 'a with grave
+ // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the
+ // default zoom level), we leave VK_[0-9] alone without translation.
+ wchar_t key;
+ if (key_code_ >= '0' && key_code_ <= '9')
+ key = key_code_;
+ else
+ key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
shortcut += key;
} else {
shortcut = l10n_util::GetString(string_id);