mirror of https://github.com/axmolengine/axmol.git
Fix textfield input chinese error with specific IME on Android.
This commit is contained in:
parent
cdf6fa8a54
commit
90ef4be103
|
@ -79,17 +79,26 @@ public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListe
|
||||||
if (this.isFullScreenEdit()) {
|
if (this.isFullScreenEdit()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int old_i = 0;
|
||||||
int nModified = s.length() - this.mText.length();
|
int new_i = 0;
|
||||||
if (nModified > 0) {
|
while (old_i < this.mText.length() && new_i < s.length()) {
|
||||||
final String insertText = s.subSequence(this.mText.length(), s.length()).toString();
|
if (this.mText.charAt(old_i) != s.charAt(new_i)) {
|
||||||
this.mCocos2dxGLSurfaceView.insertText(insertText);
|
break;
|
||||||
|
|
||||||
} else if(nModified < 0) {
|
|
||||||
for (; nModified < 0; ++nModified) {
|
|
||||||
this.mCocos2dxGLSurfaceView.deleteBackward();
|
|
||||||
}
|
}
|
||||||
|
old_i += 1;
|
||||||
|
new_i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (; old_i < this.mText.length(); ++old_i) {
|
||||||
|
this.mCocos2dxGLSurfaceView.deleteBackward();
|
||||||
|
}
|
||||||
|
|
||||||
|
int nModified = s.length() - new_i;
|
||||||
|
if (nModified > 0) {
|
||||||
|
final String insertText = s.subSequence(new_i, s.length()).toString();
|
||||||
|
this.mCocos2dxGLSurfaceView.insertText(insertText);
|
||||||
|
}
|
||||||
|
|
||||||
this.mText = s.toString();
|
this.mText = s.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue