alllow functions as argument to addKeyboardHandler
This commit is contained in:
parent
baa0c28e69
commit
75e41746e6
1 changed files with 3 additions and 1 deletions
|
|
@ -36,7 +36,7 @@ var event = require("../lib/event");
|
||||||
|
|
||||||
var KeyBinding = function(editor) {
|
var KeyBinding = function(editor) {
|
||||||
this.$editor = editor;
|
this.$editor = editor;
|
||||||
this.$data = { };
|
this.$data = {};
|
||||||
this.$handlers = [];
|
this.$handlers = [];
|
||||||
this.setDefaultHandler(editor.commands);
|
this.setDefaultHandler(editor.commands);
|
||||||
};
|
};
|
||||||
|
|
@ -63,6 +63,8 @@ var KeyBinding = function(editor) {
|
||||||
this.addKeyboardHandler = function(kb, pos) {
|
this.addKeyboardHandler = function(kb, pos) {
|
||||||
if (!kb)
|
if (!kb)
|
||||||
return;
|
return;
|
||||||
|
if (typeof kb == "function" && !kb.handleKeyboard)
|
||||||
|
kb.handleKeyboard = kb;
|
||||||
var i = this.$handlers.indexOf(kb);
|
var i = this.$handlers.indexOf(kb);
|
||||||
if (i != -1)
|
if (i != -1)
|
||||||
this.$handlers.splice(i, 1);
|
this.$handlers.splice(i, 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue