diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-01-17 14:53:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-17 14:53:16 +0100 |
commit | d46bdd04367d82e5afadf18aad0d7fb40660a6e6 (patch) | |
tree | 6ed48dae3eb62089d14eb5ebbb94ba662b474c5c | |
parent | b1017261055a815137132740e27200d50f3d2946 (diff) | |
parent | 8d41175cae53b487499fa6712f4a6a31e6ddc406 (diff) |
Merge pull request #15807 from endragor/fix-android-text-input-crash
Fix Android onTextChanged crash
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java | 11 |
1 files changed, 7 insertions, 4 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 1102ab7450..5d13f17ffb 100644 --- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java +++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java @@ -103,13 +103,16 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene 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); + final int[] newChars = new int[count]; + for (int i = start; i < start + count; ++i) { + newChars[i - start] = pCharSequence.charAt(i); + } mView.queueEvent(new Runnable() { @Override public void run() { - for (int i = start; i < start + count; ++i) { - final int ch = pCharSequence.charAt(i); - GodotLib.key(0, ch, true); - GodotLib.key(0, ch, false); + for (int i = 0; i < count; ++i) { + GodotLib.key(0, newChars[i], true); + GodotLib.key(0, newChars[i], false); } } }); |