Permalink
Browse files

Hide the characterReader inside the inputManager

Nothing outside of the inputManager should know that its using a
hidden field to read the keys. This is still awkward, but its a step
in the right direcion
  • Loading branch information...
rhburrows committed Jun 28, 2011
1 parent 8c8fb7d commit 6789e3e2ca41597e268d6e3a5429ad87068dbb9a
Showing with 16 additions and 8 deletions.
  1. +2 −7 src/core.js
  2. +13 −0 src/input.js
  3. +1 −1 test/inputTest.js
View
@@ -49,7 +49,7 @@
display.paint(editor);
$(display).bind('s2e:click', function(ev) {
- $(inputManager.characterReader).focus();
+ inputManager.focus();
editor.movePointTo(ev.position);
});
@@ -58,12 +58,7 @@
textarea.trigger(extendEvent(e, editor, display));
});
- $(inputManager.characterReader).keydown(inputManager.handler(editor));
- $(inputManager.characterReader).css({
- position: 'absolute',
- left: '-300px',
- top: '-300px'
- });
+ inputManager.keydown(inputManager.handler(editor));
return editor;
});
View
@@ -2,6 +2,11 @@
function InputManager() {
this.characterReader = document.createElement('input');
$(this.characterReader).attr('type', 'text');
+ $(this.characterReader).css({
+ position : 'absolute',
+ left : '-300px',
+ top : '-300px'
+ });
this.bindings = {};
}
@@ -121,6 +126,14 @@
return true;
}
};
+ },
+
+ focus : function() {
+ $(this.characterReader).focus();
+ },
+
+ keydown : function(f) {
+ $(this.characterReader).keydown(f);
}
};
View
@@ -1,7 +1,7 @@
module("input", {
setup: function() {
var nullEditor = {};
- inputManager = new $.fn.s2e.config.InputManager(nullEditor);
+ inputManager = new $.fn.s2e.config.InputManager();
inputHandler = inputManager.handler();
}
});

0 comments on commit 6789e3e

Please sign in to comment.