From 09c277693e951199ede72f47263088e1d2bc4c67 Mon Sep 17 00:00:00 2001 From: Guilherme Felipe Date: Wed, 31 Jan 2018 16:25:42 -0200 Subject: [PATCH] Fixes open button not appearing with multiple selection Fix #16231 --- editor/editor_file_dialog.cpp | 19 +++++++++++++++++++ editor/editor_file_dialog.h | 1 + 2 files changed, 20 insertions(+) diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index f356c168272..22b33cc98f6 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -458,6 +458,23 @@ void EditorFileDialog::_item_selected(int p_item) { get_ok()->set_disabled(_is_open_should_be_disabled()); } +void EditorFileDialog::_multi_selected(int p_item, bool p_selected) { + + int current = p_item; + if (current < 0 || current >= item_list->get_item_count()) + return; + + Dictionary d = item_list->get_item_metadata(current); + + if (!d["dir"] && p_selected) { + + file->set_text(d["name"]); + _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + } + + get_ok()->set_disabled(_is_open_should_be_disabled()); +} + void EditorFileDialog::_items_clear_selection() { item_list->unselect_all(); @@ -1290,6 +1307,7 @@ void EditorFileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorFileDialog::_unhandled_input); ClassDB::bind_method(D_METHOD("_item_selected"), &EditorFileDialog::_item_selected); + ClassDB::bind_method(D_METHOD("_multi_selected"), &EditorFileDialog::_multi_selected); ClassDB::bind_method(D_METHOD("_items_clear_selection"), &EditorFileDialog::_items_clear_selection); ClassDB::bind_method(D_METHOD("_item_list_item_rmb_selected"), &EditorFileDialog::_item_list_item_rmb_selected); ClassDB::bind_method(D_METHOD("_item_list_rmb_clicked"), &EditorFileDialog::_item_list_rmb_clicked); @@ -1598,6 +1616,7 @@ EditorFileDialog::EditorFileDialog() { connect("confirmed", this, "_action_pressed"); item_list->connect("item_selected", this, "_item_selected", varray(), CONNECT_DEFERRED); + item_list->connect("multi_selected", this, "_multi_selected", varray(), CONNECT_DEFERRED); item_list->connect("item_activated", this, "_item_db_selected", varray()); item_list->connect("nothing_selected", this, "_items_clear_selection"); dir->connect("text_entered", this, "_dir_entered"); diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 05f66eadbf5..b1f8f1108c7 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -159,6 +159,7 @@ private: void _recent_selected(int p_idx); void _item_selected(int p_item); + void _multi_selected(int p_item, bool p_selected); void _items_clear_selection(); void _item_dc_selected(int p_item);