Skip to content

Commit

Permalink
Merge pull request #51628 from timothyqiu/drag-property-path
Browse files Browse the repository at this point in the history
Allow dropping property path into script editor
  • Loading branch information
akien-mga authored Aug 13, 2021
2 parents 7ab604b + dae51cc commit 4c3ece8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions editor/plugins/script_text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,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;
}
Expand Down Expand Up @@ -1495,6 +1496,15 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
te->set_caret_column(col);
te->insert_text_at_caret(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->set_caret_line(row);
te->set_caret_column(col);
te->insert_text_at_caret(text_to_drop);
}
}

void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
Expand Down

0 comments on commit 4c3ece8

Please sign in to comment.