diff --git a/doc/classes/FileSystemDock.xml b/doc/classes/FileSystemDock.xml
index b0b23a81c64..9ea387098c3 100644
--- a/doc/classes/FileSystemDock.xml
+++ b/doc/classes/FileSystemDock.xml
@@ -87,5 +87,10 @@
Emitted when an external [param resource] had its file removed.
+
+
+ Emitted when the selection changes. Use [method EditorInterface.get_selected_paths] in the connected method to get the selected paths.
+
+
diff --git a/editor/docks/filesystem_dock.cpp b/editor/docks/filesystem_dock.cpp
index d85e72fa090..9c43787950e 100644
--- a/editor/docks/filesystem_dock.cpp
+++ b/editor/docks/filesystem_dock.cpp
@@ -3583,6 +3583,7 @@ void FileSystemDock::_tree_empty_selected() {
if (file_list_vb->is_visible()) {
_update_file_list(false);
}
+ _update_selection_changed();
}
void FileSystemDock::_file_list_item_clicked(int p_item, const Vector2 &p_pos, MouseButton p_mouse_button_index) {
@@ -3669,6 +3670,16 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) {
callable_mp(this, &FileSystemDock::_update_import_dock).call_deferred();
}
+void FileSystemDock::_update_selection_changed() {
+ Vector selection;
+ selection.append_array(_tree_get_selected());
+ selection.append_array(_file_list_get_selected());
+ if (prev_selection != selection) {
+ prev_selection = selection;
+ emit_signal(SNAME("selection_changed"));
+ }
+}
+
void FileSystemDock::_tree_mouse_exited() {
if (holding_branch) {
_reselect_items_selected_on_drag_begin();
@@ -3876,6 +3887,8 @@ void FileSystemDock::_update_import_dock() {
return;
}
+ _update_selection_changed();
+
// List selected.
Vector selected;
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
@@ -4129,6 +4142,7 @@ void FileSystemDock::_bind_methods() {
ADD_SIGNAL(MethodInfo("files_moved", PropertyInfo(Variant::STRING, "old_file"), PropertyInfo(Variant::STRING, "new_file")));
ADD_SIGNAL(MethodInfo("folder_moved", PropertyInfo(Variant::STRING, "old_folder"), PropertyInfo(Variant::STRING, "new_folder")));
ADD_SIGNAL(MethodInfo("folder_color_changed"));
+ ADD_SIGNAL(MethodInfo("selection_changed"));
ADD_SIGNAL(MethodInfo("display_mode_changed"));
}
diff --git a/editor/docks/filesystem_dock.h b/editor/docks/filesystem_dock.h
index a5ed30ad346..a035c20cd0a 100644
--- a/editor/docks/filesystem_dock.h
+++ b/editor/docks/filesystem_dock.h
@@ -253,6 +253,10 @@ private:
HashSet cached_valid_conversion_targets;
+ Vector prev_selection;
+
+ void _update_selection_changed();
+
void _tree_mouse_exited();
void _reselect_items_selected_on_drag_begin(bool reset = false);