Change how path properties are presented, so they can be edited. Fixes #20709

This commit is contained in:
Juan Linietsky 2018-08-23 11:44:36 -03:00
parent d1497b720e
commit 0d0cf2e948
2 changed files with 29 additions and 5 deletions

View File

@ -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;
}

View File

@ -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);