fix textinput and contextmenu

This commit is contained in:
nightwing 2012-05-25 00:00:10 +04:00
commit 1de8c413c6
5 changed files with 110 additions and 101 deletions

View file

@ -533,13 +533,23 @@ var VirtualRenderer = function(container, theme) {
var posLeft = this.$cursorLayer.$pixelPos.left;
posTop -= this.layerConfig.offset;
if (posTop < 0 || posTop > this.layerConfig.height)
if (posTop < 0 || posTop > this.layerConfig.height - this.lineHeight)
return;
posLeft += (this.showGutter ? this.$gutterLayer.gutterWidth : 0) - this.scrollLeft;
var bounds = this.container.getBoundingClientRect();
this.textarea.style.left = (bounds.left + posLeft) + "px";
this.textarea.style.top = (bounds.top + posTop) + "px";
var w = this.characterWidth;
if (this.$composition)
w += this.textarea.scrollWidth;
posLeft -= this.scrollLeft;
if (posLeft > this.$size.scrollerWidth - w)
posLeft = this.$size.scrollerWidth - w;
if (this.showGutter)
posLeft += this.$gutterLayer.gutterWidth;
this.textarea.style.height = this.lineHeight + "px";
this.textarea.style.width = w + "px";
this.textarea.style.left = posLeft + "px";
this.textarea.style.top = posTop - 1 + "px";
};
/**
@ -1211,21 +1221,16 @@ var VirtualRenderer = function(container, theme) {
*
**/
this.showComposition = function(position) {
if (!this.$composition) {
this.$composition = dom.createElement("div");
this.$composition.className = "ace_composition";
this.content.appendChild(this.$composition);
}
if (!this.$composition)
this.$composition = {
keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
cssText: this.textarea.style.cssText
};
this.$composition.innerHTML = "&#160;";
var pos = this.$cursorLayer.getPixelPosition();
var style = this.$composition.style;
style.top = pos.top + "px";
style.left = (pos.left + this.$padding) + "px";
style.height = this.lineHeight + "px";
this.hideCursor();
this.$keepTextAreaAtCursor = true;
dom.addCssClass(this.textarea, "ace_composition");
this.textarea.style.cssText = "";
this.$moveTextAreaToCursor();
};
/**
@ -1235,7 +1240,7 @@ var VirtualRenderer = function(container, theme) {
* Sets the inner text of the current composition to `text`.
**/
this.setCompositionText = function(text) {
dom.setInnerText(this.$composition, text);
this.$moveTextAreaToCursor();
};
/**
@ -1244,14 +1249,13 @@ var VirtualRenderer = function(container, theme) {
* Hides the current composition.
**/
this.hideComposition = function() {
this.showCursor();
if (!this.$composition)
return;
var style = this.$composition.style;
style.top = "-10000px";
style.left = "-10000px";
dom.removeCssClass(this.textarea, "ace_composition");
this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
this.textarea.style.cssText = this.$composition.cssText;
this.$composition = null;
};
this._loadTheme = function(name, callback) {