From f7cfdfb1cce033fa2ab7725dccedfc0de33b39bf Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 27 May 2021 00:29:36 +0200 Subject: [PATCH] Add preload() to resource path when holding Ctrl (cherry picked from commit 4bee21bcc4fafff2f810f9f835a39097073e0e56) --- editor/plugins/script_text_editor.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index e603ab76818..3e379197e9a 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -31,6 +31,7 @@ #include "script_text_editor.h" #include "core/math/expression.h" +#include "core/os/input.h" #include "core/os/keyboard.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" @@ -1506,11 +1507,17 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data Array files = d["files"]; String text_to_drop; + bool preload = Input::get_singleton()->is_key_pressed(KEY_CONTROL); for (int i = 0; i < files.size(); i++) { if (i > 0) { - text_to_drop += ","; + text_to_drop += ", "; + } + + if (preload) { + text_to_drop += "preload(\"" + String(files[i]).c_escape() + "\")"; + } else { + text_to_drop += "\"" + String(files[i]).c_escape() + "\""; } - text_to_drop += "\"" + String(files[i]).c_escape() + "\""; } te->cursor_set_line(row);