Fix 'LineEdit' contents not ending before the clear button if no right icon was set

Fixes #28242.
This commit is contained in:
Michael Alexsander Silva Dias 2019-04-20 18:22:37 -03:00
parent 175942dcd1
commit d84acb98d0
1 changed files with 4 additions and 2 deletions

View File

@ -1159,8 +1159,10 @@ void LineEdit::set_cursor_position(int p_pos) {
} else if (cursor_pos > window_pos) { } else if (cursor_pos > window_pos) {
/* Adjust window if cursor goes too much to the right */ /* Adjust window if cursor goes too much to the right */
int window_width = get_size().width - style->get_minimum_size().width; int window_width = get_size().width - style->get_minimum_size().width;
if (right_icon.is_valid()) { bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled;
window_width -= right_icon->get_width(); if (right_icon.is_valid() || display_clear_icon) {
Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon;
window_width -= r_icon->get_width();
} }
if (window_width < 0) if (window_width < 0)