[GUI] Enforce virtual keyboard redisplay on clear

This commit is contained in:
Sergey Minakov 2021-01-18 20:08:42 +03:00
parent 2a3e771f4c
commit ba6aa76992
2 changed files with 20 additions and 15 deletions

View File

@ -121,13 +121,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
selection.creating = false; selection.creating = false;
selection.doubleclick = false; selection.doubleclick = false;
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) { show_virtual_keyboard();
if (selection.enabled) {
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), false, max_length, selection.begin, selection.end);
} else {
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), false, max_length, cursor_pos);
}
}
} }
update(); update();
@ -953,14 +947,7 @@ void LineEdit::_notification(int p_what) {
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id()); DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
} }
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) { show_virtual_keyboard();
if (selection.enabled) {
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), false, max_length, selection.begin, selection.end);
} else {
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), false, max_length, cursor_pos);
}
}
} break; } break;
case NOTIFICATION_FOCUS_EXIT: { case NOTIFICATION_FOCUS_EXIT: {
if (caret_blink_enabled && !caret_force_displayed) { if (caret_blink_enabled && !caret_force_displayed) {
@ -1407,6 +1394,21 @@ Array LineEdit::get_structured_text_bidi_override_options() const {
void LineEdit::clear() { void LineEdit::clear() {
clear_internal(); clear_internal();
_text_changed(); _text_changed();
// This should reset virtual keyboard state if needed.
if (has_focus()) {
show_virtual_keyboard();
}
}
void LineEdit::show_virtual_keyboard() {
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) {
if (selection.enabled) {
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), false, max_length, selection.begin, selection.end);
} else {
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), false, max_length, cursor_pos);
}
}
} }
String LineEdit::get_text() const { String LineEdit::get_text() const {

View File

@ -306,6 +306,9 @@ public:
Ref<Texture2D> get_right_icon(); Ref<Texture2D> get_right_icon();
virtual bool is_text_field() const override; virtual bool is_text_field() const override;
void show_virtual_keyboard();
LineEdit(); LineEdit();
~LineEdit(); ~LineEdit();
}; };