summaryrefslogtreecommitdiff
path: root/editor/editor_properties.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r--editor/editor_properties.cpp37
1 files changed, 33 insertions, 4 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 07df2cedd5..97a38b9200 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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);
@@ -2883,8 +2909,11 @@ void EditorPropertyResource::_resource_changed(const RES &p_resource) {
}
}
-void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool) {
- emit_signal(SNAME("property_keyed_with_value"), String(get_edited_property()) + ":" + p_property, p_value, false);
+void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool p_advance) {
+ // The second parameter could be null, causing the event to fire with less arguments, so use the pointer call which preserves it.
+ const Variant args[3] = { String(get_edited_property()) + ":" + p_property, p_value, p_advance };
+ const Variant *argp[3] = { &args[0], &args[1], &args[2] };
+ emit_signal(SNAME("property_keyed_with_value"), argp, 3);
}
void EditorPropertyResource::_sub_inspector_resource_selected(const RES &p_resource, const String &p_property) {