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
commit dff0c41fe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1284,12 +1284,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;
}
@ -1330,6 +1327,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<Resource> res = d["resource"];
@ -1342,7 +1343,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") {
@ -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() + "\"";
}
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") {
@ -1386,7 +1391,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);
}
}