fix ime issues
This commit is contained in:
parent
846f712969
commit
09bc6119d4
2 changed files with 17 additions and 4 deletions
|
|
@ -231,6 +231,7 @@ var TextInput = function(parentNode, host) {
|
||||||
afterContextMenu = false;
|
afterContextMenu = false;
|
||||||
};
|
};
|
||||||
var onInput = function(e) {
|
var onInput = function(e) {
|
||||||
|
// console.log("onInput", inComposition)
|
||||||
if (inComposition)
|
if (inComposition)
|
||||||
return;
|
return;
|
||||||
var data = text.value;
|
var data = text.value;
|
||||||
|
|
@ -349,6 +350,8 @@ var TextInput = function(parentNode, host) {
|
||||||
|
|
||||||
// COMPOSITION
|
// COMPOSITION
|
||||||
var onCompositionStart = function(e) {
|
var onCompositionStart = function(e) {
|
||||||
|
if (inComposition) return;
|
||||||
|
// console.log("onCompositionStart", inComposition)
|
||||||
inComposition = {};
|
inComposition = {};
|
||||||
host.onCompositionStart();
|
host.onCompositionStart();
|
||||||
setTimeout(onCompositionUpdate, 0);
|
setTimeout(onCompositionUpdate, 0);
|
||||||
|
|
@ -362,6 +365,7 @@ var TextInput = function(parentNode, host) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var onCompositionUpdate = function() {
|
var onCompositionUpdate = function() {
|
||||||
|
// console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
|
||||||
if (!inComposition) return;
|
if (!inComposition) return;
|
||||||
host.onCompositionUpdate(text.value);
|
host.onCompositionUpdate(text.value);
|
||||||
if (inComposition.lastValue)
|
if (inComposition.lastValue)
|
||||||
|
|
@ -378,19 +382,28 @@ var TextInput = function(parentNode, host) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var onCompositionEnd = function(e) {
|
var onCompositionEnd = function(e) {
|
||||||
|
// console.log("onCompositionEnd", inComposition &&inComposition.lastValue)
|
||||||
var c = inComposition;
|
var c = inComposition;
|
||||||
inComposition = false;
|
inComposition = false;
|
||||||
var timer = setTimeout(function() {
|
var timer = setTimeout(function() {
|
||||||
var str = text.value.replace(/\x01/g, "");
|
var str = text.value.replace(/\x01/g, "");
|
||||||
if (!inComposition && str == c.lastValue)
|
console.log(str, c.lastValue)
|
||||||
|
if (inComposition)
|
||||||
|
return
|
||||||
|
else if (str == c.lastValue)
|
||||||
resetValue();
|
resetValue();
|
||||||
|
else if (!c.lastValue && str) {
|
||||||
|
resetValue();
|
||||||
|
sendText(str);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
inputHandler = function compositionInputHandler(str) {
|
inputHandler = function compositionInputHandler(str) {
|
||||||
|
// console.log("onCompositionEnd", str, c.lastValue)
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
str = str.replace(/\x01/g, "");
|
str = str.replace(/\x01/g, "");
|
||||||
if (str == c.lastValue)
|
if (str == c.lastValue)
|
||||||
return "";
|
return "";
|
||||||
if (!str) {
|
if (str) {
|
||||||
if (c.lastValue)
|
if (c.lastValue)
|
||||||
host.undo();
|
host.undo();
|
||||||
}
|
}
|
||||||
|
|
@ -398,7 +411,7 @@ var TextInput = function(parentNode, host) {
|
||||||
}
|
}
|
||||||
host.onCompositionEnd();
|
host.onCompositionEnd();
|
||||||
host.removeListener("mousedown", onCompositionEnd);
|
host.removeListener("mousedown", onCompositionEnd);
|
||||||
if (e.type == "compositionend") {
|
if (e.type == "compositionend" && c.range) {
|
||||||
host.selection.setRange(c.range);
|
host.selection.setRange(c.range);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -545,7 +545,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
var w = this.characterWidth;
|
var w = this.characterWidth;
|
||||||
if (this.$composition) {
|
if (this.$composition) {
|
||||||
var val = this.textarea.value.replace(/^\x01+/, "");
|
var val = this.textarea.value.replace(/^\x01+/, "");
|
||||||
w *= this.session.$getStringScreenWidth(val)[0];
|
w *= (this.session.$getStringScreenWidth(val)[0]+2);
|
||||||
h += 2;
|
h += 2;
|
||||||
posTop -= 1;
|
posTop -= 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue