summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-02-01 14:14:36 +0100
committerGitHub <noreply@github.com>2018-02-01 14:14:36 +0100
commit5585f011c5d0e07d1f18e13602c86376aece26c4 (patch)
treebf034c10e017504c2ce99d6a2401887064ddd207
parente7cf2b2e77a097a026f883f003ad299b5d451885 (diff)
parent09c277693e951199ede72f47263088e1d2bc4c67 (diff)
Merge pull request #16251 from guilhermefelipecgs/fix_open_button_for_multiple_select
Fixes open button not appearing with multiple selection
-rw-r--r--editor/editor_file_dialog.cpp19
-rw-r--r--editor/editor_file_dialog.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index f356c16827..22b33cc98f 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 05f66eadbf..b1f8f1108c 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);