summaryrefslogtreecommitdiff
path: root/editor/editor_inspector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r--editor/editor_inspector.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 0e5fd3a999..1078fabc2e 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1366,7 +1366,28 @@ void EditorInspector::update_tree() {
//to update properly if all is refreshed
StringName current_selected = property_selected;
- int current_focusable = property_focusable;
+ int current_focusable = -1;
+
+ if (property_focusable != -1) {
+ //check focusable is really focusable
+ bool restore_focus = false;
+ Control *focused = get_focus_owner();
+ if (focused) {
+ Node *parent = focused->get_parent();
+ while (parent) {
+ EditorInspector *inspector = Object::cast_to<EditorInspector>(parent);
+ if (inspector) {
+ restore_focus = inspector == this; //may be owned by another inspector
+ break; //exit after the first inspector is found, since there may be nested ones
+ }
+ parent = parent->get_parent();
+ }
+ }
+
+ if (restore_focus) {
+ current_focusable = property_focusable;
+ }
+ }
_clear();
@@ -1878,13 +1899,13 @@ int EditorInspector::get_scroll_offset() const {
return get_v_scroll();
}
-void EditorInspector::set_use_sub_inspector_bg(bool p_enable) {
+void EditorInspector::set_sub_inspector(bool p_enable) {
- use_sub_inspector_bg = p_enable;
+ sub_inspector = p_enable;
if (!is_inside_tree())
return;
- if (use_sub_inspector_bg) {
+ if (sub_inspector) {
add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
} else {
add_style_override("bg", get_stylebox("bg", "Tree"));
@@ -1989,7 +2010,7 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v
}
}
-void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value) {
+void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
update_tree();
}
@@ -2105,16 +2126,18 @@ void EditorInspector::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- get_tree()->connect("node_removed", this, "_node_removed");
- if (use_sub_inspector_bg) {
+ if (sub_inspector) {
add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
- } else if (is_inside_tree()) {
+ } else {
add_style_override("bg", get_stylebox("bg", "Tree"));
+ get_tree()->connect("node_removed", this, "_node_removed");
}
}
if (p_what == NOTIFICATION_EXIT_TREE) {
- get_tree()->disconnect("node_removed", this, "_node_removed");
+ if (!sub_inspector) {
+ get_tree()->disconnect("node_removed", this, "_node_removed");
+ }
edit(NULL);
}
@@ -2163,7 +2186,7 @@ void EditorInspector::_notification(int p_what) {
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- if (use_sub_inspector_bg) {
+ if (sub_inspector) {
add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
} else if (is_inside_tree()) {
add_style_override("bg", get_stylebox("bg", "Tree"));
@@ -2259,7 +2282,7 @@ EditorInspector::EditorInspector() {
_prop_edited = "property_edited";
set_process(true);
property_focusable = -1;
- use_sub_inspector_bg = false;
+ sub_inspector = false;
get_v_scrollbar()->connect("value_changed", this, "_vscroll_changed");
update_scroll_request = -1;