Corrected text selection in color picker

Fixes #35603

(cherry picked from commit 77b70aa79d)
This commit is contained in:
janglee 2020-03-24 17:11:09 +05:30 committed by Rémi Verschelde
parent a51e78528f
commit e1ca49b4b6
1 changed files with 12 additions and 5 deletions

View File

@ -624,26 +624,33 @@ void ColorPicker::_screen_pick_pressed() {
} }
void ColorPicker::_focus_enter() { void ColorPicker::_focus_enter() {
if (c_text->has_focus()) { bool has_ctext_focus = c_text->has_focus();
if (has_ctext_focus) {
c_text->select_all(); c_text->select_all();
return; } else {
c_text->select(0, 0);
} }
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (values[i]->get_line_edit()->has_focus()) { if (values[i]->get_line_edit()->has_focus() && !has_ctext_focus) {
values[i]->get_line_edit()->select_all(); values[i]->get_line_edit()->select_all();
break; } else {
values[i]->get_line_edit()->select(0, 0);
} }
} }
} }
void ColorPicker::_focus_exit() { void ColorPicker::_focus_exit() {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
values[i]->get_line_edit()->select(0, 0); if (!values[i]->get_line_edit()->get_menu()->is_visible())
values[i]->get_line_edit()->select(0, 0);
} }
c_text->select(0, 0); c_text->select(0, 0);
} }
void ColorPicker::_html_focus_exit() { void ColorPicker::_html_focus_exit() {
if (c_text->get_menu()->is_visible())
return;
_html_entered(c_text->get_text()); _html_entered(c_text->get_text());
_focus_exit(); _focus_exit();
} }