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;
|
||||
};
|
||||
var onInput = function(e) {
|
||||
// console.log("onInput", inComposition)
|
||||
if (inComposition)
|
||||
return;
|
||||
var data = text.value;
|
||||
|
|
@ -349,6 +350,8 @@ var TextInput = function(parentNode, host) {
|
|||
|
||||
// COMPOSITION
|
||||
var onCompositionStart = function(e) {
|
||||
if (inComposition) return;
|
||||
// console.log("onCompositionStart", inComposition)
|
||||
inComposition = {};
|
||||
host.onCompositionStart();
|
||||
setTimeout(onCompositionUpdate, 0);
|
||||
|
|
@ -362,6 +365,7 @@ var TextInput = function(parentNode, host) {
|
|||
};
|
||||
|
||||
var onCompositionUpdate = function() {
|
||||
// console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
|
||||
if (!inComposition) return;
|
||||
host.onCompositionUpdate(text.value);
|
||||
if (inComposition.lastValue)
|
||||
|
|
@ -378,19 +382,28 @@ var TextInput = function(parentNode, host) {
|
|||
};
|
||||
|
||||
var onCompositionEnd = function(e) {
|
||||
// console.log("onCompositionEnd", inComposition &&inComposition.lastValue)
|
||||
var c = inComposition;
|
||||
inComposition = false;
|
||||
var timer = setTimeout(function() {
|
||||
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();
|
||||
else if (!c.lastValue && str) {
|
||||
resetValue();
|
||||
sendText(str);
|
||||
}
|
||||
});
|
||||
inputHandler = function compositionInputHandler(str) {
|
||||
// console.log("onCompositionEnd", str, c.lastValue)
|
||||
clearTimeout(timer);
|
||||
str = str.replace(/\x01/g, "");
|
||||
if (str == c.lastValue)
|
||||
return "";
|
||||
if (!str) {
|
||||
if (str) {
|
||||
if (c.lastValue)
|
||||
host.undo();
|
||||
}
|
||||
|
|
@ -398,7 +411,7 @@ var TextInput = function(parentNode, host) {
|
|||
}
|
||||
host.onCompositionEnd();
|
||||
host.removeListener("mousedown", onCompositionEnd);
|
||||
if (e.type == "compositionend") {
|
||||
if (e.type == "compositionend" && c.range) {
|
||||
host.selection.setRange(c.range);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -545,7 +545,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
var w = this.characterWidth;
|
||||
if (this.$composition) {
|
||||
var val = this.textarea.value.replace(/^\x01+/, "");
|
||||
w *= this.session.$getStringScreenWidth(val)[0];
|
||||
w *= (this.session.$getStringScreenWidth(val)[0]+2);
|
||||
h += 2;
|
||||
posTop -= 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue