From ad425b7e9fe965fceb565ca1401075ce0f8448be Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Fri, 13 Aug 2021 23:01:45 +0800 Subject: [PATCH] Allow dropping property path into script editor --- editor/plugins/script_text_editor.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 4c01c9ea929..da2a67337c9 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1452,6 +1452,7 @@ bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_ if (d.has("type") && (String(d["type"]) == "resource" || String(d["type"]) == "files" || String(d["type"]) == "nodes" || + String(d["type"]) == "obj_property" || String(d["type"]) == "files_and_dirs")) { return true; } @@ -1555,6 +1556,15 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data te->cursor_set_column(col); te->insert_text_at_cursor(text_to_drop); } + + if (d.has("type") && String(d["type"]) == "obj_property") { + const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\""; + const String text_to_drop = String(d["property"]).c_escape().quote(quote_style); + + te->cursor_set_line(row); + te->cursor_set_column(col); + te->insert_text_at_cursor(text_to_drop); + } } void ScriptTextEditor::_text_edit_gui_input(const Ref &ev) {