commit
d097d41144
3 changed files with 25 additions and 11 deletions
|
|
@ -75,7 +75,14 @@ var TextInput = function(parentNode, host) {
|
||||||
host.onFocus(e);
|
host.onFocus(e);
|
||||||
resetSelection();
|
resetSelection();
|
||||||
});
|
});
|
||||||
this.focus = function() { text.focus(); };
|
this.focus = function() {
|
||||||
|
text.style.position = "fixed";
|
||||||
|
text.style.top = "-10000000px";
|
||||||
|
text.focus();
|
||||||
|
setTimeout(function() {
|
||||||
|
text.style.position = "";
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
this.blur = function() { text.blur(); };
|
this.blur = function() { text.blur(); };
|
||||||
this.isFocused = function() {
|
this.isFocused = function() {
|
||||||
return isFocused;
|
return isFocused;
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,11 @@ var MouseHandler = function(editor) {
|
||||||
new DragdropHandler(this);
|
new DragdropHandler(this);
|
||||||
|
|
||||||
var focusEditor = function(e) {
|
var focusEditor = function(e) {
|
||||||
if (!editor.isFocused() && editor.textInput)
|
// because we have to call event.preventDefault() any window on ie and iframes
|
||||||
editor.textInput.moveToMouse(e);
|
// on other browsers do not get focus, so we have to call window.focus() here
|
||||||
editor.focus()
|
if (!document.hasFocus || !document.hasFocus())
|
||||||
|
window.focus();
|
||||||
|
editor.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
var mouseTarget = editor.renderer.getMouseEventTarget();
|
var mouseTarget = editor.renderer.getMouseEventTarget();
|
||||||
|
|
|
||||||
|
|
@ -375,6 +375,9 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
if (this.resizing)
|
if (this.resizing)
|
||||||
this.resizing = 0;
|
this.resizing = 0;
|
||||||
|
// reset cached values on scrollbars, needs to be removed when switching to non-native scrollbars
|
||||||
|
// see https://github.com/ajaxorg/ace/issues/2195
|
||||||
|
this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$updateCachedSize = function(force, gutterWidth, width, height) {
|
this.$updateCachedSize = function(force, gutterWidth, width, height) {
|
||||||
|
|
@ -634,9 +637,12 @@ var VirtualRenderer = function(container, theme) {
|
||||||
var posLeft = this.$cursorLayer.$pixelPos.left;
|
var posLeft = this.$cursorLayer.$pixelPos.left;
|
||||||
posTop -= config.offset;
|
posTop -= config.offset;
|
||||||
|
|
||||||
|
var style = this.textarea.style;
|
||||||
var h = this.lineHeight;
|
var h = this.lineHeight;
|
||||||
if (posTop < 0 || posTop > config.height - h)
|
if (posTop < 0 || posTop > config.height - h) {
|
||||||
|
style.top = style.left = "0";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var w = this.characterWidth;
|
var w = this.characterWidth;
|
||||||
if (this.$composition) {
|
if (this.$composition) {
|
||||||
|
|
@ -649,11 +655,10 @@ var VirtualRenderer = function(container, theme) {
|
||||||
posLeft = this.$size.scrollerWidth - w;
|
posLeft = this.$size.scrollerWidth - w;
|
||||||
|
|
||||||
posLeft += this.gutterWidth;
|
posLeft += this.gutterWidth;
|
||||||
|
style.height = h + "px";
|
||||||
this.textarea.style.height = h + "px";
|
style.width = w + "px";
|
||||||
this.textarea.style.width = w + "px";
|
style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
|
||||||
this.textarea.style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
|
style.top = Math.min(posTop, this.$size.height - h) + "px";
|
||||||
this.textarea.style.top = Math.min(posTop, this.$size.height - h) + "px";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue