1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Merge pull request #16374 from ianb96/drop_at_mouse

Drop path text at mouse pos
This commit is contained in:
Rémi Verschelde
2018-02-13 11:25:55 +01:00
committed by GitHub

View File

@@ -1284,10 +1284,7 @@ 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 { bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
Dictionary d = p_data; Dictionary d = p_data;
if (d.has("type") && if (d.has("type") && (String(d["type"]) == "resource" ||
(
String(d["type"]) == "resource" ||
String(d["type"]) == "files" || String(d["type"]) == "files" ||
String(d["type"]) == "nodes")) { String(d["type"]) == "nodes")) {
@@ -1330,6 +1327,10 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
Dictionary d = 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") { if (d.has("type") && String(d["type"]) == "resource") {
Ref<Resource> res = d["resource"]; Ref<Resource> res = d["resource"];
@@ -1342,7 +1343,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
return; 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") { if (d.has("type") && String(d["type"]) == "files") {
@@ -1357,7 +1360,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
text_to_drop += "\"" + String(files[i]).c_escape() + "\""; 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") { if (d.has("type") && String(d["type"]) == "nodes") {
@@ -1386,7 +1391,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
text_to_drop += "\"" + path.c_escape() + "\""; 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);
} }
} }