From 8cbb154466c4555f8ea44ebb9ea98f8a0e4c9877 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 1 Jul 2016 10:55:35 -0300 Subject: Color picker was getting too much focus, made it get not as much focus. This abuse of focus was the original culprit of #5354 --- scene/gui/color_picker.cpp | 12 ++++++++---- scene/gui/color_picker.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index d6bbdf2d21..06f8c27957 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -72,13 +72,16 @@ void ColorPicker::_notification(int p_what) { _update_color(); } - case NOTIFICATION_VISIBILITY_CHANGED: { - c_text->call_deferred("grab_focus"); - c_text->call_deferred("select"); - } break; + } } +void ColorPicker::set_focus_on_line_edit() { + + c_text->grab_focus(); + c_text->select(); +} + void ColorPicker::_update_controls() { if (edit_alpha) { @@ -628,6 +631,7 @@ void ColorPickerButton::pressed() { popup->set_pos(get_global_pos()-Size2(0,ms.height)); popup->set_size(ms); popup->popup(); + picker->set_focus_on_line_edit(); } diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index f5de982200..b9ef1f1e2f 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -107,6 +107,7 @@ public: void set_raw_mode(bool p_enabled); bool is_raw_mode() const; + void set_focus_on_line_edit(); ColorPicker(); }; -- cgit v1.2.3