diff options
-rw-r--r-- | editor/editor_properties.cpp | 29 | ||||
-rw-r--r-- | editor/editor_properties.h | 5 |
2 files changed, 29 insertions, 5 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 5f1e7273e5..3c3df6b8ef 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -258,19 +258,40 @@ void EditorPropertyPath::setup(const Vector<String> &p_extensions, bool p_folder global = p_global; } +void EditorPropertyPath::_notification(int p_what) { + + if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { + path_edit->set_icon(get_icon("Folder", "EditorIcons")); + } +} + +void EditorPropertyPath::_path_focus_exited() { + + _path_selected(path->get_text()); +} + void EditorPropertyPath::_bind_methods() { ClassDB::bind_method(D_METHOD("_path_pressed"), &EditorPropertyPath::_path_pressed); ClassDB::bind_method(D_METHOD("_path_selected"), &EditorPropertyPath::_path_selected); + ClassDB::bind_method(D_METHOD("_path_focus_exited"), &EditorPropertyPath::_path_focus_exited); } EditorPropertyPath::EditorPropertyPath() { - path = memnew(Button); - path->set_clip_text(true); - add_child(path); + HBoxContainer *path_hb = memnew(HBoxContainer); + add_child(path_hb); + path = memnew(LineEdit); + path_hb->add_child(path); + path->connect("text_entered", this, "_path_selected"); + path->connect("focus_exited", this, "_path_focus_exited"); + path->set_h_size_flags(SIZE_EXPAND_FILL); + + path_edit = memnew(Button); + path_edit->set_clip_text(true); + path_hb->add_child(path_edit); add_focusable(path); dialog = NULL; - path->connect("pressed", this, "_path_pressed"); + path_edit->connect("pressed", this, "_path_pressed"); folder = false; global = false; } diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 5726ccfa41..cfc433b880 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -107,13 +107,16 @@ class EditorPropertyPath : public EditorProperty { bool folder; bool global; EditorFileDialog *dialog; - Button *path; + LineEdit *path; + Button *path_edit; void _path_selected(const String &p_path); void _path_pressed(); + void _path_focus_exited(); protected: static void _bind_methods(); + void _notification(int p_what); public: void setup(const Vector<String> &p_extensions, bool p_folder, bool p_global); |