alllow functions as argument to addKeyboardHandler

This commit is contained in:
nightwing 2014-01-30 20:49:38 +04:00
commit 75e41746e6

View file

@ -36,7 +36,7 @@ var event = require("../lib/event");
var KeyBinding = function(editor) {
this.$editor = editor;
this.$data = { };
this.$data = {};
this.$handlers = [];
this.setDefaultHandler(editor.commands);
};
@ -63,6 +63,8 @@ var KeyBinding = function(editor) {
this.addKeyboardHandler = function(kb, pos) {
if (!kb)
return;
if (typeof kb == "function" && !kb.handleKeyboard)
kb.handleKeyboard = kb;
var i = this.$handlers.indexOf(kb);
if (i != -1)
this.$handlers.splice(i, 1);