mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Merge pull request #5298 from phamdaniel/fix-mac-accelerators
Fix converting from windows virtual keycode back to mac keycode
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user