diff options
Diffstat (limited to 'scene/gui/file_dialog.cpp')
-rw-r--r-- | scene/gui/file_dialog.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index a7205cef66..3be77ff4b3 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -85,7 +85,7 @@ void FileDialog::_unhandled_input(const Ref<InputEvent> &p_event) { bool handled = true; - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_H: { @@ -135,7 +135,8 @@ Vector<String> FileDialog::get_selected_files() const { void FileDialog::update_dir() { - dir->set_text(dir_access->get_current_dir()); + dir->set_text(dir_access->get_current_dir(false)); + if (drives->is_visible()) { drives->select(dir_access->get_current_drive()); } @@ -789,6 +790,12 @@ void FileDialog::_update_drives() { drives->hide(); } else { drives->clear(); + Node *dp = drives->get_parent(); + if (dp) { + dp->remove_child(drives); + } + dp = dir_access->drives_are_shortcuts() ? shortcuts_container : drives_container; + dp->add_child(drives); drives->show(); for (int i = 0; i < dir_access->get_drive_count(); i++) { @@ -829,6 +836,7 @@ void FileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("is_showing_hidden_files"), &FileDialog::is_showing_hidden_files); ClassDB::bind_method(D_METHOD("_update_file_name"), &FileDialog::update_file_name); ClassDB::bind_method(D_METHOD("_update_dir"), &FileDialog::update_dir); + ClassDB::bind_method(D_METHOD("_update_file_list"), &FileDialog::update_file_list); ClassDB::bind_method(D_METHOD("deselect_items"), &FileDialog::deselect_items); ClassDB::bind_method(D_METHOD("invalidate"), &FileDialog::invalidate); @@ -889,11 +897,14 @@ FileDialog::FileDialog() { hbc->add_child(dir_up); dir_up->connect("pressed", callable_mp(this, &FileDialog::_go_up)); + hbc->add_child(memnew(Label(RTR("Path:")))); + + drives_container = memnew(HBoxContainer); + hbc->add_child(drives_container); + drives = memnew(OptionButton); - hbc->add_child(drives); drives->connect("item_selected", callable_mp(this, &FileDialog::_select_drive)); - hbc->add_child(memnew(Label(RTR("Path:")))); dir = memnew(LineEdit); hbc->add_child(dir); dir->set_h_size_flags(SIZE_EXPAND_FILL); @@ -910,6 +921,9 @@ FileDialog::FileDialog() { show_hidden->connect("toggled", callable_mp(this, &FileDialog::set_show_hidden_files)); hbc->add_child(show_hidden); + shortcuts_container = memnew(HBoxContainer); + hbc->add_child(shortcuts_container); + makedir = memnew(Button); makedir->set_text(RTR("Create Folder")); makedir->connect("pressed", callable_mp(this, &FileDialog::_make_dir)); |