Skip to content

Commit e0cdba4

Browse files
committed
Merge pull request #99453 from reach-satori/drag_to_filesystem_folder
Allow dragging to specific folders in filesystem dock
2 parents ffe0cde + 6f76ef4 commit e0cdba4

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

editor/editor_node.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5844,7 +5844,11 @@ PopupMenu *EditorNode::get_export_as_menu() {
58445844
}
58455845

58465846
void EditorNode::_dropped_files(const Vector<String> &p_files) {
5847-
String to_path = ProjectSettings::get_singleton()->globalize_path(FileSystemDock::get_singleton()->get_current_directory());
5847+
String to_path = FileSystemDock::get_singleton()->get_folder_path_at_mouse_position();
5848+
if (to_path.is_empty()) {
5849+
to_path = FileSystemDock::get_singleton()->get_current_directory();
5850+
}
5851+
to_path = ProjectSettings::get_singleton()->globalize_path(to_path);
58485852

58495853
_add_dropped_files_recursive(p_files, to_path);
58505854

editor/filesystem_dock.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2799,6 +2799,15 @@ void FileSystemDock::remove_resource_tooltip_plugin(const Ref<EditorResourceTool
27992799
tooltip_plugins.remove_at(index);
28002800
}
28012801

2802+
String FileSystemDock::get_folder_path_at_mouse_position() const {
2803+
TreeItem *item = tree->get_item_at_position(tree->get_local_mouse_position());
2804+
if (!item) {
2805+
return String();
2806+
}
2807+
String fpath = item->get_metadata(0);
2808+
return fpath.get_base_dir();
2809+
}
2810+
28022811
Control *FileSystemDock::create_tooltip_for_path(const String &p_path) const {
28032812
if (p_path == "Favorites") {
28042813
// No tooltip for the "Favorites" group.

editor/filesystem_dock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ class FileSystemDock : public VBoxContainer {
381381

382382
String get_current_path() const;
383383
String get_current_directory() const;
384+
String get_folder_path_at_mouse_position() const;
384385

385386
void navigate_to_path(const String &p_path);
386387
void focus_on_path();

0 commit comments

Comments
 (0)