diff options
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r-- | editor/editor_inspector.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index dd912eac42..36462f6805 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -414,6 +414,18 @@ StringName EditorProperty::get_edited_property() const { return property; } +EditorInspector *EditorProperty::get_parent_inspector() const { + Node *parent = get_parent(); + while (parent) { + EditorInspector *ei = Object::cast_to<EditorInspector>(parent); + if (ei) { + return ei; + } + parent = parent->get_parent(); + } + ERR_FAIL_V_MSG(nullptr, "EditorProperty is outside inspector."); +} + void EditorProperty::set_doc_path(const String &p_doc_path) { doc_path = p_doc_path; } @@ -693,7 +705,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { bool is_valid_revert = false; Variant revert_value = EditorPropertyRevert::get_property_revert_value(object, property, &is_valid_revert); ERR_FAIL_COND(!is_valid_revert); - emit_changed(property, revert_value); + emit_changed(_get_revert_property(), revert_value); update_property(); } @@ -2484,6 +2496,10 @@ Button *EditorInspector::create_inspector_action_button(const String &p_text) { return button; } +bool EditorInspector::is_main_editor_inspector() const { + return InspectorDock::get_singleton() && InspectorDock::get_inspector_singleton() == this; +} + String EditorInspector::get_selected_path() const { return property_selected; } @@ -3286,7 +3302,7 @@ void EditorInspector::update_tree() { _parse_added_editors(main_vbox, nullptr, ped); } - if (_is_main_editor_inspector()) { + if (is_main_editor_inspector()) { // Updating inspector might invalidate some editing owners. EditorNode::get_singleton()->hide_unused_editors(); } @@ -3316,7 +3332,7 @@ void EditorInspector::_clear(bool p_hide_plugins) { pending.clear(); restart_request_props.clear(); - if (p_hide_plugins && _is_main_editor_inspector()) { + if (p_hide_plugins && is_main_editor_inspector()) { EditorNode::get_singleton()->hide_unused_editors(this); } } @@ -3652,10 +3668,6 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo } } -bool EditorInspector::_is_main_editor_inspector() const { - return InspectorDock::get_singleton() && InspectorDock::get_inspector_singleton() == this; -} - void EditorInspector::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing, bool p_update_all) { // The "changing" variable must be true for properties that trigger events as typing occurs, // like "text_changed" signal. E.g. text property of Label, Button, RichTextLabel, etc. |