mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
Add a remove all key mapping function (#4498)
This commit is contained in:
@@ -104,10 +104,7 @@ Blockly.ShortcutRegistry.prototype.unregister = function(shortcutName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove all key mappings with this shortcut.
|
||||
for (var keyCode in this.keyMap_) {
|
||||
this.removeKeyMapping(keyCode, shortcutName, true);
|
||||
}
|
||||
this.removeAllKeyMappings(shortcutName);
|
||||
|
||||
delete this.registry_[shortcutName];
|
||||
return true;
|
||||
@@ -178,6 +175,19 @@ Blockly.ShortcutRegistry.prototype.removeKeyMapping = function(
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all the key mappings for a shortcut with the given name.
|
||||
* Useful when changing the default key mappings and the key codes registered to the shortcut are
|
||||
* unknown.
|
||||
* @param {string} shortcutName The name of the shortcut to remove from the key map.
|
||||
* @public
|
||||
*/
|
||||
Blockly.ShortcutRegistry.prototype.removeAllKeyMappings = function(shortcutName) {
|
||||
for (var keyCode in this.keyMap_) {
|
||||
this.removeKeyMapping(keyCode, shortcutName, true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the key map. Setting the key map will override any default key mappings.
|
||||
* @param {!Object<string, !Array<string>>} keyMap The object with key code to
|
||||
|
||||
Reference in New Issue
Block a user