move hidden text area over the cursor
This commit is contained in:
parent
383e493fa0
commit
56c97c992c
1 changed files with 24 additions and 1 deletions
|
|
@ -43,11 +43,34 @@ var TextInput = function(parentNode, host) {
|
|||
|
||||
var text = document.createElement("textarea");
|
||||
var style = text.style;
|
||||
style.position = "absolute";
|
||||
style.position = "fixed";
|
||||
style.left = "-10000px";
|
||||
style.top = "-10000px";
|
||||
parentNode.appendChild(text);
|
||||
|
||||
// move text input over the cursor
|
||||
// this is required for iOS and IME
|
||||
style.left = "0px";
|
||||
style.top = "0px";
|
||||
style.zIndex = -1;
|
||||
style.opacity = 0;
|
||||
style.width = "10px";
|
||||
style.height = "30px";
|
||||
|
||||
var changeCursor = function() {
|
||||
var cursor = host.getCursorPosition();
|
||||
var pos = host.renderer.textToScreenCoordinates(cursor.row, cursor.column);
|
||||
var epos = parentNode.getBoundingClientRect();
|
||||
style.left = (pos.pageX - epos.left - 6) + "px";
|
||||
style.top = (pos.pageY - epos.top + 52) + "px";
|
||||
};
|
||||
|
||||
host.addEventListener("changeSession", function(e) {
|
||||
if (e.oldSession)
|
||||
e.oldSession.getSelection().removeEventListener("changeCursor", changeCursor);
|
||||
e.session.getSelection().addEventListener("changeCursor", changeCursor);
|
||||
});
|
||||
|
||||
var PLACEHOLDER = String.fromCharCode(0);
|
||||
sendText();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue