summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2022-04-10 21:25:24 +0200
committerkobewi <kobewi4e@gmail.com>2022-04-11 00:37:06 +0200
commit63de41b996db09e37816d941506b14753d8ed233 (patch)
tree488c2a3a3cfd316675555ca92a9d45a69287e3d2
parent83d26737727f281afcb33f66fea5d09ed6c48d5a (diff)
Improvements to files_dropped signal
-rw-r--r--doc/classes/Window.xml9
-rw-r--r--editor/editor_node.cpp2
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/project_manager.cpp2
-rw-r--r--editor/project_manager.h2
-rw-r--r--scene/main/window.cpp2
6 files changed, 14 insertions, 5 deletions
diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml
index 9853f906bc..87a65db192 100644
--- a/doc/classes/Window.xml
+++ b/doc/classes/Window.xml
@@ -349,6 +349,15 @@
<argument index="0" name="files" type="PackedStringArray" />
<description>
Emitted when files are dragged from the OS file manager and dropped in the game window. The argument is a list of file paths.
+ Note that this method only works with non-embedded windows, i.e. the main window and [Window]-derived nodes when [member Viewport.gui_embed_subwindows] is disabled in the main viewport.
+ Example usage:
+ [codeblock]
+ func _ready():
+ get_viewport().files_dropped.connect(on_files_dropped)
+
+ func on_files_dropped(files):
+ print(files)
+ [/codeblock]
</description>
</signal>
<signal name="focus_entered">
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index a80c7853f5..1a1e16027e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -5478,7 +5478,7 @@ void EditorNode::_global_menu_new_window(const Variant &p_tag) {
}
}
-void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
+void EditorNode::_dropped_files(const Vector<String> &p_files) {
String to_path = ProjectSettings::get_singleton()->globalize_path(FileSystemDock::get_singleton()->get_selected_path());
_add_dropped_files_recursive(p_files, to_path);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 685714cb47..c6c1f09938 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -575,7 +575,7 @@ private:
void _open_recent_scene(int p_idx);
void _global_menu_scene(const Variant &p_tag);
void _global_menu_new_window(const Variant &p_tag);
- void _dropped_files(const Vector<String> &p_files, int p_screen);
+ void _dropped_files(const Vector<String> &p_files);
void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path);
void _update_from_settings();
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 501cb88547..eedcd0d3ef 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -2402,7 +2402,7 @@ void ProjectManager::_install_project(const String &p_zip_path, const String &p_
npdialog->show_dialog();
}
-void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) {
+void ProjectManager::_files_dropped(PackedStringArray p_files) {
if (p_files.size() == 1 && p_files[0].ends_with(".zip")) {
const String file = p_files[0].get_file();
_install_project(p_files[0], file.substr(0, file.length() - 4).capitalize());
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 9cea6e163f..00f8cfc721 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -127,7 +127,7 @@ class ProjectManager : public Control {
void _dim_window();
virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
- void _files_dropped(PackedStringArray p_files, int p_screen);
+ void _files_dropped(PackedStringArray p_files);
void _version_button_pressed();
void _on_order_option_changed(int p_idx);
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 2faa107fb4..2858ffba6d 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -981,7 +981,7 @@ void Window::_window_input_text(const String &p_text) {
}
void Window::_window_drop_files(const Vector<String> &p_files) {
- emit_signal(SNAME("files_dropped"), p_files, current_screen);
+ emit_signal(SNAME("files_dropped"), p_files);
}
Viewport *Window::get_parent_viewport() const {