Fix Return key events in LineEdit & TextEdit on Android

Depending on the device implementation, editor actions could be
received with different action ids or not at all for multi-line.

Added a parameter to virtual keyboards to properly handle single-line
and multi-line cases in all situations.

Single-line:
Input type set to text without multiline to make sure actions are sent.
IME options are set to DONE action to force action id consistency.

Multi-line:
Input type set to text and multiline to make sure enter triggers new lines.
Actions are disabled by the multiline flag, so '\n' characters are
handled in text changed callbacks.
This commit is contained in:
PouleyKetchoupp
2020-07-17 17:44:13 +02:00
parent 89f57ae122
commit c0b394572f
18 changed files with 49 additions and 30 deletions

View File

@ -129,9 +129,9 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (OS::get_singleton()->has_virtual_keyboard()) {
if (selection.enabled) {
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), max_length, selection.begin, selection.end);
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), false, max_length, selection.begin, selection.end);
} else {
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), max_length, cursor_pos);
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), false, max_length, cursor_pos);
}
}
}
@ -326,6 +326,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
return;
} break;
case KEY_BACKSPACE: {
@ -932,9 +933,9 @@ void LineEdit::_notification(int p_what) {
if (OS::get_singleton()->has_virtual_keyboard()) {
if (selection.enabled) {
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), max_length, selection.begin, selection.end);
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), false, max_length, selection.begin, selection.end);
} else {
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), max_length, cursor_pos);
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), false, max_length, cursor_pos);
}
}
} break;

View File

@ -1741,7 +1741,7 @@ void TextEdit::_notification(int p_what) {
OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect());
OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect(), true);
} break;
case NOTIFICATION_FOCUS_EXIT: {