diff options
author | volzhs <volzhs@gmail.com> | 2017-03-04 00:12:35 +0900 |
---|---|---|
committer | volzhs <volzhs@gmail.com> | 2017-03-04 00:15:26 +0900 |
commit | 4866ea828ae544868034a5f2e4c95adb7ba67e59 (patch) | |
tree | 04fa17cb6969faaa2309f7640882f9eba73eacc5 /platform/android | |
parent | 74eace2b14b337e23d0dc552f3bc3e60f1710f65 (diff) |
Fix handling input for Android
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java index 80cded6fb5..3c8207fae1 100644 --- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java +++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java @@ -49,7 +49,6 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene // =========================================================== private final GodotView mView; private final GodotEditText mEdit; - private String mText; private String mOriginText; // =========================================================== @@ -81,52 +80,28 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene @Override public void afterTextChanged(final Editable s) { - if (this.isFullScreenEdit()) { - return; - } - //if (BuildConfig.DEBUG) { - //Log.d(TAG, "afterTextChanged: " + s); - //} - int nModified = s.length() - this.mText.length(); - if (nModified > 0) { - final String insertText = s.subSequence(this.mText.length(), s.length()).toString(); - for(int i = 0; i < insertText.length(); i++) { - int ch = insertText.codePointAt(i); - GodotLib.key(0, ch, true); - GodotLib.key(0, ch, false); - } - /* - if (BuildConfig.DEBUG) { - Log.d(TAG, "insertText(" + insertText + ")"); - } - */ - } else { - for (; nModified < 0; ++nModified) { - GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true); - GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false); - /* - if (BuildConfig.DEBUG) { - Log.d(TAG, "deleteBackward"); - } - */ - } - } - this.mText = s.toString(); } @Override public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) { - /* - if (BuildConfig.DEBUG) { - Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after); + //Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after); + + for (int i=0;i<count;i++){ + GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true); + GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false); } - */ - this.mText = pCharSequence.toString(); } @Override public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) { + //Log.d(TAG, "onTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",before: " + before); + + for (int i=start;i<start+count;i++){ + int ch = pCharSequence.charAt(i); + GodotLib.key(0, ch, true); + GodotLib.key(0, ch, false); + } } |