You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Merge pull request #107275 from DexterFstone/file-system-selection-changed-signal
Expose the signal when user select a file/folder in the FileSystemDock
This commit is contained in:
@@ -87,5 +87,10 @@
|
|||||||
Emitted when an external [param resource] had its file removed.
|
Emitted when an external [param resource] had its file removed.
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
|
<signal name="selection_changed">
|
||||||
|
<description>
|
||||||
|
Emitted when the selection changes. Use [method EditorInterface.get_selected_paths] in the connected method to get the selected paths.
|
||||||
|
</description>
|
||||||
|
</signal>
|
||||||
</signals>
|
</signals>
|
||||||
</class>
|
</class>
|
||||||
|
|||||||
@@ -3609,6 +3609,7 @@ void FileSystemDock::_tree_empty_selected() {
|
|||||||
if (file_list_vb->is_visible()) {
|
if (file_list_vb->is_visible()) {
|
||||||
_update_file_list(false);
|
_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) {
|
void FileSystemDock::_file_list_item_clicked(int p_item, const Vector2 &p_pos, MouseButton p_mouse_button_index) {
|
||||||
@@ -3701,6 +3702,16 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) {
|
|||||||
callable_mp(this, &FileSystemDock::_update_import_dock).call_deferred();
|
callable_mp(this, &FileSystemDock::_update_import_dock).call_deferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileSystemDock::_update_selection_changed() {
|
||||||
|
Vector<String> 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() {
|
void FileSystemDock::_tree_mouse_exited() {
|
||||||
if (holding_branch) {
|
if (holding_branch) {
|
||||||
_reselect_items_selected_on_drag_begin();
|
_reselect_items_selected_on_drag_begin();
|
||||||
@@ -3908,6 +3919,8 @@ void FileSystemDock::_update_import_dock() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_update_selection_changed();
|
||||||
|
|
||||||
// List selected.
|
// List selected.
|
||||||
Vector<String> selected;
|
Vector<String> selected;
|
||||||
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
|
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
|
||||||
@@ -4165,6 +4178,7 @@ void FileSystemDock::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("files_moved", PropertyInfo(Variant::STRING, "old_file"), PropertyInfo(Variant::STRING, "new_file")));
|
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_moved", PropertyInfo(Variant::STRING, "old_folder"), PropertyInfo(Variant::STRING, "new_folder")));
|
||||||
ADD_SIGNAL(MethodInfo("folder_color_changed"));
|
ADD_SIGNAL(MethodInfo("folder_color_changed"));
|
||||||
|
ADD_SIGNAL(MethodInfo("selection_changed"));
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("display_mode_changed"));
|
ADD_SIGNAL(MethodInfo("display_mode_changed"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,6 +256,10 @@ private:
|
|||||||
|
|
||||||
HashSet<String> cached_valid_conversion_targets;
|
HashSet<String> cached_valid_conversion_targets;
|
||||||
|
|
||||||
|
Vector<String> prev_selection;
|
||||||
|
|
||||||
|
void _update_selection_changed();
|
||||||
|
|
||||||
void _tree_mouse_exited();
|
void _tree_mouse_exited();
|
||||||
void _reselect_items_selected_on_drag_begin(bool reset = false);
|
void _reselect_items_selected_on_drag_begin(bool reset = false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user