summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-08-23 11:44:36 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-08-23 11:45:54 -0300
commit0d0cf2e9489ce80bc077fc1a9b7811dec9047faa (patch)
tree7e1a97e8579e0abba4d286a11e4b738d02daf37e /editor
parentd1497b720eb34da7797e5107c357f6ed17b37297 (diff)
Change how path properties are presented, so they can be edited. Fixes #20709
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_properties.cpp29
-rw-r--r--editor/editor_properties.h5
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);