diff options
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r-- | editor/editor_properties.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 07df2cedd5..eb1a0a2031 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2727,6 +2727,29 @@ void EditorPropertyNodePath::_node_clear() { update_property(); } +bool EditorPropertyNodePath::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { + return !is_read_only() && is_drop_valid(p_data); +} + +void EditorPropertyNodePath::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { + ERR_FAIL_COND(!is_drop_valid(p_data)); + Dictionary data = p_data; + Array nodes = data["nodes"]; + Node *node = get_tree()->get_edited_scene_root()->get_node(nodes[0]); + + if (node) { + _node_selected(node->get_path()); + } +} + +bool EditorPropertyNodePath::is_drop_valid(const Dictionary &p_drag_data) const { + if (p_drag_data["type"] != "nodes") { + return false; + } + Array nodes = p_drag_data["nodes"]; + return nodes.size() == 1; +} + void EditorPropertyNodePath::update_property() { NodePath p = get_edited_object()->get(get_edited_property()); @@ -2781,6 +2804,8 @@ void EditorPropertyNodePath::_notification(int p_what) { } void EditorPropertyNodePath::_bind_methods() { + ClassDB::bind_method(D_METHOD("_can_drop_data_fw", "position", "data", "from"), &EditorPropertyNodePath::can_drop_data_fw); + ClassDB::bind_method(D_METHOD("_drop_data_fw", "position", "data", "from"), &EditorPropertyNodePath::drop_data_fw); } EditorPropertyNodePath::EditorPropertyNodePath() { @@ -2791,6 +2816,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() { assign->set_h_size_flags(SIZE_EXPAND_FILL); assign->set_clip_text(true); assign->connect("pressed", callable_mp(this, &EditorPropertyNodePath::_node_assign)); + assign->set_drag_forwarding(this); hbc->add_child(assign); clear = memnew(Button); |