1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

Fix "\" keyboard shortcut on German keyboard layouts

Summary: Ref T10252. This is similar to D16259, but makes KeyboardShortcutManager more relaxed about `altKey` when typing obscure characters.

Test Plan: Pressed Option + Shift + 7 on a German keyboard layout, saw Conphernece sidebar toggle.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10252

Differential Revision: https://secure.phabricator.com/D16260
This commit is contained in:
epriestley 2016-07-08 08:30:30 -07:00
parent a8a9fddb07
commit 444e353700
2 changed files with 33 additions and 11 deletions

View file

@ -8,7 +8,7 @@
return array( return array(
'names' => array( 'names' => array(
'core.pkg.css' => '2fbe65a2', 'core.pkg.css' => '2fbe65a2',
'core.pkg.js' => 'f2139810', 'core.pkg.js' => '49f8bdc0',
'darkconsole.pkg.js' => 'e7393ebb', 'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '3e81ae60', 'differential.pkg.css' => '3e81ae60',
'differential.pkg.js' => '634399e9', 'differential.pkg.js' => '634399e9',
@ -463,7 +463,7 @@ return array(
'rsrc/js/core/FileUpload.js' => '680ea2c8', 'rsrc/js/core/FileUpload.js' => '680ea2c8',
'rsrc/js/core/Hovercard.js' => '1bd28176', 'rsrc/js/core/Hovercard.js' => '1bd28176',
'rsrc/js/core/KeyboardShortcut.js' => '1ae869f2', 'rsrc/js/core/KeyboardShortcut.js' => '1ae869f2',
'rsrc/js/core/KeyboardShortcutManager.js' => 'c1700f6f', 'rsrc/js/core/KeyboardShortcutManager.js' => '4a021c10',
'rsrc/js/core/MultirowRowManager.js' => 'b5d57730', 'rsrc/js/core/MultirowRowManager.js' => 'b5d57730',
'rsrc/js/core/Notification.js' => 'ccf1cbf8', 'rsrc/js/core/Notification.js' => 'ccf1cbf8',
'rsrc/js/core/Prefab.js' => 'cfd23f37', 'rsrc/js/core/Prefab.js' => 'cfd23f37',
@ -780,7 +780,7 @@ return array(
'phabricator-filetree-view-css' => 'fccf9f82', 'phabricator-filetree-view-css' => 'fccf9f82',
'phabricator-flag-css' => '5337623f', 'phabricator-flag-css' => '5337623f',
'phabricator-keyboard-shortcut' => '1ae869f2', 'phabricator-keyboard-shortcut' => '1ae869f2',
'phabricator-keyboard-shortcut-manager' => 'c1700f6f', 'phabricator-keyboard-shortcut-manager' => '4a021c10',
'phabricator-main-menu-view' => 'b623169f', 'phabricator-main-menu-view' => 'b623169f',
'phabricator-nav-view-css' => 'ac79a758', 'phabricator-nav-view-css' => 'ac79a758',
'phabricator-notification' => 'ccf1cbf8', 'phabricator-notification' => 'ccf1cbf8',
@ -1222,6 +1222,13 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-stratcom', 'javelin-stratcom',
), ),
'4a021c10' => array(
'javelin-install',
'javelin-util',
'javelin-stratcom',
'javelin-dom',
'javelin-vector',
),
'4b700e9e' => array( '4b700e9e' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',
@ -1882,13 +1889,6 @@ return array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',
), ),
'c1700f6f' => array(
'javelin-install',
'javelin-util',
'javelin-stratcom',
'javelin-dom',
'javelin-vector',
),
'c587b80f' => array( 'c587b80f' => array(
'javelin-install', 'javelin-install',
), ),

View file

@ -32,6 +32,18 @@ JX.install('KeyboardShortcutManager', {
down: 1 down: 1
}, },
/**
* Some keys require Alt to be pressed in order to type them on certain
* keyboard layouts.
*/
_altkeys: {
// "Alt+L" on German layouts.
'@': 1,
// "Alt+Shift+7" on German layouts.
'\\': 1
},
getInstance : function() { getInstance : function() {
if (!JX.KeyboardShortcutManager._instance) { if (!JX.KeyboardShortcutManager._instance) {
JX.KeyboardShortcutManager._instance = new JX.KeyboardShortcutManager(); JX.KeyboardShortcutManager._instance = new JX.KeyboardShortcutManager();
@ -119,14 +131,24 @@ JX.install('KeyboardShortcutManager', {
} }
}, },
_onkeyhit : function(e) { _onkeyhit : function(e) {
var self = JX.KeyboardShortcutManager;
var raw = e.getRawEvent(); var raw = e.getRawEvent();
if (raw.altKey || raw.ctrlKey || raw.metaKey) { if (raw.ctrlKey || raw.metaKey) {
// Never activate keyboard shortcuts if modifier keys are also // Never activate keyboard shortcuts if modifier keys are also
// depressed. // depressed.
return; return;
} }
// For most keystrokes, don't activate keyboard shortcuts if the Alt
// key is depressed. However, we continue if the character requires the
// use of Alt to type it on some keyboard layouts.
var key = this._getKey(e);
if (raw.altKey && !(key in self._altkeys)) {
return;
}
var target = e.getTarget(); var target = e.getTarget();
var ignore = ['input', 'select', 'textarea', 'object', 'embed']; var ignore = ['input', 'select', 'textarea', 'object', 'embed'];
if (JX.DOM.isType(target, ignore)) { if (JX.DOM.isType(target, ignore)) {