fix multi byte input, rendering(Windows XP IE8, Firefox3.6, Chrome8)
This commit is contained in:
parent
af3a08da38
commit
84a2ceb28d
1 changed files with 30 additions and 6 deletions
|
|
@ -38,6 +38,7 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var event = require("pilot/event");
|
var event = require("pilot/event");
|
||||||
|
var useragent = require("pilot/useragent");
|
||||||
|
|
||||||
var TextInput = function(parentNode, host) {
|
var TextInput = function(parentNode, host) {
|
||||||
|
|
||||||
|
|
@ -77,6 +78,7 @@ var TextInput = function(parentNode, host) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var onTextInput = function(e) {
|
var onTextInput = function(e) {
|
||||||
|
if (useragent.isIE && text.value.charCodeAt(0) > 128) return;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (!inCompostion)
|
if (!inCompostion)
|
||||||
sendText();
|
sendText();
|
||||||
|
|
@ -85,20 +87,25 @@ var TextInput = function(parentNode, host) {
|
||||||
|
|
||||||
var onCompositionStart = function(e) {
|
var onCompositionStart = function(e) {
|
||||||
inCompostion = true;
|
inCompostion = true;
|
||||||
sendText();
|
if (!useragent.isIE) {
|
||||||
text.value = "";
|
sendText();
|
||||||
|
text.value = "";
|
||||||
|
};
|
||||||
host.onCompositionStart();
|
host.onCompositionStart();
|
||||||
setTimeout(onCompositionUpdate, 0);
|
if (!useragent.isGecko) setTimeout(onCompositionUpdate, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onCompositionUpdate = function() {
|
var onCompositionUpdate = function() {
|
||||||
|
if (!inCompostion) return;
|
||||||
host.onCompositionUpdate(text.value);
|
host.onCompositionUpdate(text.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onCompositionEnd = function() {
|
var onCompositionEnd = function() {
|
||||||
inCompostion = false;
|
inCompostion = false;
|
||||||
host.onCompositionEnd();
|
host.onCompositionEnd();
|
||||||
onTextInput();
|
setTimeout(function () {
|
||||||
|
sendText();
|
||||||
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onCopy = function() {
|
var onCopy = function() {
|
||||||
|
|
@ -119,6 +126,16 @@ var TextInput = function(parentNode, host) {
|
||||||
|
|
||||||
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
|
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
|
||||||
event.addListener(text, "keypress", onTextInput);
|
event.addListener(text, "keypress", onTextInput);
|
||||||
|
if (useragent.isIE) {
|
||||||
|
var keytable = { 13:1, 27:1 };
|
||||||
|
event.addListener(text, "keyup", function (e) {
|
||||||
|
if (inCompostion && (!text.value || keytable[e.keyCode])) setTimeout(onCompositionEnd, 0);
|
||||||
|
if ((text.value.charCodeAt(0)|0) < 129) {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
inCompostion ? onCompositionUpdate() : onCompositionStart();
|
||||||
|
});
|
||||||
|
};
|
||||||
event.addListener(text, "textInput", onTextInput);
|
event.addListener(text, "textInput", onTextInput);
|
||||||
event.addListener(text, "paste", function(e) {
|
event.addListener(text, "paste", function(e) {
|
||||||
// Some browsers support the event.clipboardData API. Use this to get
|
// Some browsers support the event.clipboardData API. Use this to get
|
||||||
|
|
@ -133,13 +150,20 @@ var TextInput = function(parentNode, host) {
|
||||||
onTextInput();
|
onTextInput();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
event.addListener(text, "propertychange", onTextInput);
|
if (!useragent.isIE) {
|
||||||
|
event.addListener(text, "propertychange", onTextInput);
|
||||||
|
};
|
||||||
|
|
||||||
event.addListener(text, "copy", onCopy);
|
event.addListener(text, "copy", onCopy);
|
||||||
event.addListener(text, "cut", onCut);
|
event.addListener(text, "cut", onCut);
|
||||||
|
|
||||||
event.addListener(text, "compositionstart", onCompositionStart);
|
event.addListener(text, "compositionstart", onCompositionStart);
|
||||||
event.addListener(text, "compositionupdate", onCompositionUpdate);
|
if (useragent.isGecko) {
|
||||||
|
event.addListener(text, "text", onCompositionUpdate);
|
||||||
|
};
|
||||||
|
if (useragent.isWebKit) {
|
||||||
|
event.addListener(text, "keyup", onCompositionUpdate);
|
||||||
|
};
|
||||||
event.addListener(text, "compositionend", onCompositionEnd);
|
event.addListener(text, "compositionend", onCompositionEnd);
|
||||||
|
|
||||||
event.addListener(text, "blur", function() {
|
event.addListener(text, "blur", function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue