diff options
Diffstat (limited to 'scene/gui/line_edit.cpp')
-rw-r--r-- | scene/gui/line_edit.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 5351b6cadc..7afc3b0d00 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -128,7 +128,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { selection.doubleclick = false; if (OS::get_singleton()->has_virtual_keyboard()) - OS::get_singleton()->show_virtual_keyboard(text, get_global_rect()); + OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), max_length); } update(); @@ -913,7 +913,7 @@ void LineEdit::_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(text, get_global_rect()); + OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), max_length); } break; case NOTIFICATION_FOCUS_EXIT: { @@ -1193,7 +1193,7 @@ void LineEdit::delete_char() { set_cursor_position(get_cursor_position() - 1); if (align == ALIGN_CENTER || align == ALIGN_RIGHT) { - window_pos = CLAMP(window_pos - 1, 0, text.length() - 1); + window_pos = CLAMP(window_pos - 1, 0, MAX(text.length() - 1, 0)); } _text_changed(); @@ -1224,7 +1224,7 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) { } if (align == ALIGN_CENTER || align == ALIGN_RIGHT) { - window_pos = CLAMP(window_pos - (p_to_column - p_from_column), 0, text.length() - 1); + window_pos = CLAMP(window_pos - (p_to_column - p_from_column), 0, MAX(text.length() - 1, 0)); } if (!text_changed_dirty) { @@ -1239,6 +1239,11 @@ void LineEdit::set_text(String p_text) { clear_internal(); append_at_cursor(p_text); + + if (expand_to_text_length) { + minimum_size_changed(); + } + update(); cursor_pos = 0; window_pos = 0; @@ -1482,6 +1487,7 @@ void LineEdit::set_editable(bool p_editable) { editable = p_editable; _generate_context_menu(); + minimum_size_changed(); update(); } @@ -1617,7 +1623,11 @@ bool LineEdit::get_expand_to_text_length() const { } void LineEdit::set_clear_button_enabled(bool p_enabled) { + if (clear_button_enabled == p_enabled) { + return; + } clear_button_enabled = p_enabled; + minimum_size_changed(); update(); } @@ -1653,6 +1663,7 @@ void LineEdit::set_right_icon(const Ref<Texture> &p_icon) { return; } right_icon = p_icon; + minimum_size_changed(); update(); } |