add removeCommand function
This commit is contained in:
parent
ea4d070bfd
commit
44c019871c
1 changed files with 16 additions and 0 deletions
|
|
@ -20,6 +20,22 @@ var CommandManager = function(commands) {
|
||||||
this._buildKeyHash(command);
|
this._buildKeyHash(command);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function removeCommand(command) {
|
||||||
|
var name = (typeof command === 'string' ? command : command.name);
|
||||||
|
command = this.commands[name];
|
||||||
|
delete commands[name];
|
||||||
|
|
||||||
|
// exaustive search is a little bit brute force but since removeCommand is
|
||||||
|
// not a performance critical operation this should be OK
|
||||||
|
var ckb = this.commmandKeyBinding;
|
||||||
|
for (var hashId in ckb) {
|
||||||
|
for (var key in ckb[hashId]) {
|
||||||
|
if (ckb[hashId][key] == command)
|
||||||
|
delete ckb[hashId][key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var platform = useragent.isMac ? "mac" : "win";
|
var platform = useragent.isMac ? "mac" : "win";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue