Skip to content

Commit 6f76ef4

Browse files
author
Mateus Reis
committed
Allow dragging to specific folders in filesystem dock
1 parent a0cd8f1 commit 6f76ef4

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
@@ -5828,7 +5828,11 @@ PopupMenu *EditorNode::get_export_as_menu() {
58285828
}
58295829

58305830
void EditorNode::_dropped_files(const Vector<String> &p_files) {
5831-
String to_path = ProjectSettings::get_singleton()->globalize_path(FileSystemDock::get_singleton()->get_current_directory());
5831+
String to_path = FileSystemDock::get_singleton()->get_folder_path_at_mouse_position();
5832+
if (to_path.is_empty()) {
5833+
to_path = FileSystemDock::get_singleton()->get_current_directory();
5834+
}
5835+
to_path = ProjectSettings::get_singleton()->globalize_path(to_path);
58325836

58335837
_add_dropped_files_recursive(p_files, to_path);
58345838

editor/filesystem_dock.cpp

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

2752+
String FileSystemDock::get_folder_path_at_mouse_position() const {
2753+
TreeItem *item = tree->get_item_at_position(tree->get_local_mouse_position());
2754+
if (!item) {
2755+
return String();
2756+
}
2757+
String fpath = item->get_metadata(0);
2758+
return fpath.get_base_dir();
2759+
}
2760+
27522761
Control *FileSystemDock::create_tooltip_for_path(const String &p_path) const {
27532762
if (p_path == "Favorites") {
27542763
// No tooltip for the "Favorites" group.

editor/filesystem_dock.h

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

381381
String get_current_path() const;
382382
String get_current_directory() const;
383+
String get_folder_path_at_mouse_position() const;
383384

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

0 commit comments

Comments
 (0)