From 06965f2770a5ee25db1691174d22d2a4a8e9116a Mon Sep 17 00:00:00 2001 From: ianb96 Date: Sat, 3 Feb 2018 21:33:32 -0500 Subject: drop path text at mouse pos --- editor/plugins/script_text_editor.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'editor') diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index a3728a1d46..3e00039c84 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1283,12 +1283,9 @@ Variant ScriptTextEditor::get_drag_data_fw(const Point2 &p_point, Control *p_fro bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { Dictionary d = p_data; - if (d.has("type") && - ( - - String(d["type"]) == "resource" || - String(d["type"]) == "files" || - String(d["type"]) == "nodes")) { + if (d.has("type") && (String(d["type"]) == "resource" || + String(d["type"]) == "files" || + String(d["type"]) == "nodes")) { return true; } @@ -1329,6 +1326,10 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data Dictionary d = p_data; + TextEdit *te = code_editor->get_text_edit(); + int row, col; + te->_get_mouse_pos(p_point, row, col); + if (d.has("type") && String(d["type"]) == "resource") { Ref res = d["resource"]; @@ -1341,7 +1342,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data return; } - code_editor->get_text_edit()->insert_text_at_cursor(res->get_path()); + te->cursor_set_line(row); + te->cursor_set_column(col); + te->insert_text_at_cursor(res->get_path()); } if (d.has("type") && String(d["type"]) == "files") { @@ -1356,7 +1359,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data text_to_drop += "\"" + String(files[i]).c_escape() + "\""; } - code_editor->get_text_edit()->insert_text_at_cursor(text_to_drop); + te->cursor_set_line(row); + te->cursor_set_column(col); + te->insert_text_at_cursor(text_to_drop); } if (d.has("type") && String(d["type"]) == "nodes") { @@ -1385,7 +1390,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data text_to_drop += "\"" + path.c_escape() + "\""; } - code_editor->get_text_edit()->insert_text_at_cursor(text_to_drop); + te->cursor_set_line(row); + te->cursor_set_column(col); + te->insert_text_at_cursor(text_to_drop); } } -- cgit v1.2.3