:apple: Fix converting from windows virtual keycode back to mac keycode
authorDaniel Pham <pham.dany@gmail.com>
Tue, 26 Apr 2016 03:23:16 +0000 (23:23 -0400)
committerDaniel Pham <pham.dany@gmail.com>
Tue, 26 Apr 2016 14:53:26 +0000 (10:53 -0400)
atom/browser/ui/accelerator_util_mac.mm

index be631b0..d339588 100644 (file)
@@ -13,12 +13,6 @@ namespace accelerator_util {
 void SetPlatformAccelerator(ui::Accelerator* accelerator) {
   unichar character;
   unichar characterIgnoringModifiers;
-  ui::MacKeyCodeForWindowsKeyCode(accelerator->key_code(),
-                                  0,
-                                  &character,
-                                  &characterIgnoringModifiers);
-  NSString* characters =
-      [[[NSString alloc] initWithCharacters:&character length:1] autorelease];
 
   NSUInteger modifiers =
       (accelerator->IsCtrlDown() ? NSControlKeyMask : 0) |
@@ -26,6 +20,18 @@ void SetPlatformAccelerator(ui::Accelerator* accelerator) {
       (accelerator->IsAltDown() ? NSAlternateKeyMask : 0) |
       (accelerator->IsShiftDown() ? NSShiftKeyMask : 0);
 
+  ui::MacKeyCodeForWindowsKeyCode(accelerator->key_code(),
+                                  modifiers,
+                                  &character,
+                                  &characterIgnoringModifiers);
+
+  if (character != characterIgnoringModifiers) {
+    modifiers ^= NSShiftKeyMask;
+  }
+
+  NSString* characters =
+      [[[NSString alloc] initWithCharacters:&character length:1] autorelease];
+
   scoped_ptr<ui::PlatformAccelerator> platform_accelerator(
       new ui::PlatformAcceleratorCocoa(characters, modifiers));
   accelerator->set_platform_accelerator(std::move(platform_accelerator));