diff options
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r-- | editor/editor_properties.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 1c1d72e7d1..3c3df6b8ef 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -72,6 +72,10 @@ void EditorPropertyText::update_property() { updating = false; } +void EditorPropertyText::set_placeholder(const String &p_string) { + text->set_placeholder(p_string); +} + void EditorPropertyText::_bind_methods() { ClassDB::bind_method(D_METHOD("_text_changed", "txt"), &EditorPropertyText::_text_changed); @@ -254,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; } @@ -2783,6 +2808,9 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ } else { EditorPropertyText *editor = memnew(EditorPropertyText); + if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) { + editor->set_placeholder(p_hint_text); + } add_property_editor(p_path, editor); } } break; |