Update method names in shortcut registry (#4479)

This commit is contained in:
alschmiedt
2020-11-30 10:52:09 -08:00
committed by GitHub
parent 9b6d15a3bc
commit 97117bdb12
2 changed files with 5 additions and 5 deletions

View File

@@ -218,7 +218,7 @@ Blockly.ShortcutRegistry.prototype.getRegistry = function() {
*/
Blockly.ShortcutRegistry.prototype.onKeyDown = function(workspace, e) {
var key = this.serializeKeyEvent_(e);
var shortcutNames = this.getKeyboardShortcuts(key);
var shortcutNames = this.getShortcutNamesByKeyCode(key);
if (!shortcutNames) {
return false;
}
@@ -241,7 +241,7 @@ Blockly.ShortcutRegistry.prototype.onKeyDown = function(workspace, e) {
* given keyCode is used. Undefined if no shortcuts exist.
* @public
*/
Blockly.ShortcutRegistry.prototype.getKeyboardShortcuts = function(
Blockly.ShortcutRegistry.prototype.getShortcutNamesByKeyCode = function(
keyCode) {
return this.keyMap_[keyCode] || [];
};
@@ -254,7 +254,7 @@ Blockly.ShortcutRegistry.prototype.getKeyboardShortcuts = function(
* registered under.
* @public
*/
Blockly.ShortcutRegistry.prototype.getKeyCodeByShortcutName = function(
Blockly.ShortcutRegistry.prototype.getKeyCodesByShortcutName = function(
shortcutName) {
var keys = [];
for (var keyCode in this.keyMap_) {

View File

@@ -200,14 +200,14 @@ suite('Keyboard Shortcut Registry Test', function() {
});
test('Gets keyboard shortcuts from a key code', function() {
this.registry.keyMap_['keyCode'] = ['shortcutName'];
var shortcutNames = this.registry.getKeyboardShortcuts('keyCode');
var shortcutNames = this.registry.getShortcutNamesByKeyCode('keyCode');
chai.assert.equal(shortcutNames[0], 'shortcutName');
});
test('Gets keycodes by shortcut name', function() {
this.registry.keyMap_['keyCode'] = ['shortcutName'];
this.registry.keyMap_['keyCode1'] = ['shortcutName'];
var shortcutNames =
this.registry.getKeyCodeByShortcutName('shortcutName');
this.registry.getKeyCodesByShortcutName('shortcutName');
chai.assert.lengthOf(shortcutNames, 2);
chai.assert.equal(shortcutNames[0], 'keyCode');
chai.assert.equal(shortcutNames[1], 'keyCode1');