mirror of
https://github.com/google/blockly.git
synced 2026-01-07 17:10:11 +01:00
Update method names in shortcut registry (#4479)
This commit is contained in:
@@ -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_) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user