mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix the bug causing java.lang.StringIndexOutOfBoundsException
crashes when showing the virtual keyboard
(cherry picked from commit ff3eee7df6
)
This commit is contained in:
parent
e146c46214
commit
ce8f9dfea8
1 changed files with 12 additions and 8 deletions
|
@ -276,16 +276,20 @@ public class GodotEditText extends EditText {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cursorStart = p_cursor_start;
|
||||||
|
int cursorEnd = p_cursor_end;
|
||||||
int maxInputLength = (p_max_input_length <= 0) ? Integer.MAX_VALUE : p_max_input_length;
|
int maxInputLength = (p_max_input_length <= 0) ? Integer.MAX_VALUE : p_max_input_length;
|
||||||
if (p_cursor_start == -1) { // cursor position not given
|
if (cursorStart == -1) { // cursor position not given
|
||||||
this.mOriginText = p_existing_text;
|
this.mOriginText = p_existing_text;
|
||||||
this.mMaxInputLength = maxInputLength;
|
this.mMaxInputLength = maxInputLength;
|
||||||
} else if (p_cursor_end == -1) { // not text selection
|
} else if (cursorEnd == -1) { // not text selection
|
||||||
this.mOriginText = p_existing_text.substring(0, p_cursor_start);
|
cursorStart = Math.min(p_existing_text.length(), cursorStart);
|
||||||
this.mMaxInputLength = maxInputLength - (p_existing_text.length() - p_cursor_start);
|
this.mOriginText = p_existing_text.substring(0, cursorStart);
|
||||||
|
this.mMaxInputLength = maxInputLength - (p_existing_text.length() - cursorStart);
|
||||||
} else {
|
} else {
|
||||||
this.mOriginText = p_existing_text.substring(0, p_cursor_end);
|
cursorEnd = Math.min(p_existing_text.length(), cursorEnd);
|
||||||
this.mMaxInputLength = maxInputLength - (p_existing_text.length() - p_cursor_end);
|
this.mOriginText = p_existing_text.substring(0, cursorEnd);
|
||||||
|
this.mMaxInputLength = maxInputLength - (p_existing_text.length() - cursorEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mKeyboardType = p_type;
|
this.mKeyboardType = p_type;
|
||||||
|
@ -293,8 +297,8 @@ public class GodotEditText extends EditText {
|
||||||
final Message msg = new Message();
|
final Message msg = new Message();
|
||||||
msg.what = HANDLER_OPEN_IME_KEYBOARD;
|
msg.what = HANDLER_OPEN_IME_KEYBOARD;
|
||||||
msg.obj = this;
|
msg.obj = this;
|
||||||
msg.arg1 = p_cursor_start;
|
msg.arg1 = cursorStart;
|
||||||
msg.arg2 = p_cursor_end;
|
msg.arg2 = cursorEnd;
|
||||||
sHandler.sendMessage(msg);
|
sHandler.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue