diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-07-01 10:55:35 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-07-01 10:55:35 -0300 |
commit | 8cbb154466c4555f8ea44ebb9ea98f8a0e4c9877 (patch) | |
tree | 6e69479cfb3f3d5929727a24aaed085de6016d49 | |
parent | 3185ce64c5c27c3ce7c4ce755bfc890bac172f04 (diff) |
Color picker was getting too much focus, made it get not as much focus.
This abuse of focus was the original culprit of #5354
-rw-r--r-- | scene/gui/color_picker.cpp | 12 | ||||
-rw-r--r-- | scene/gui/color_picker.h | 1 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 8 | ||||
-rw-r--r-- | tools/editor/property_editor.cpp | 1 |
4 files changed, 18 insertions, 4 deletions
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(); }; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 8df7bb4791..9f98eee39f 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2058,7 +2058,15 @@ void Viewport::_gui_input_event(InputEvent p_event) { case InputEvent::JOYSTICK_BUTTON: case InputEvent::KEY: { + if (gui.key_focus && !gui.key_focus->is_visible()) { + Node *c=gui.key_focus; + String p; + while(c) { + p=c->get_type()+"/"+p; + c=c->get_parent(); + } + print_line(p); //key focus must always be visible gui.key_focus->release_focus(); } diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 246785932d..e0dc76e733 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -612,6 +612,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA); color_picker->set_color(v); set_size( Size2(300*EDSCALE, color_picker->get_combined_minimum_size().height+10*EDSCALE)); + color_picker->set_focus_on_line_edit(); /* int ofs=80; int m=10; |