summaryrefslogtreecommitdiffstats
path: root/editor/editor_inspector.cpp
diff options
context:
space:
mode:
authorMarius Hanl <mariushanl@web.de>2024-09-04 00:26:09 +0200
committerMarius Hanl <mariushanl@web.de>2024-09-04 01:20:11 +0200
commit27b7b433e03114c72c89397633d82fd67e0b0b8c (patch)
tree9f2493340fd57e52e9334429b210208a71b49d0f /editor/editor_inspector.cpp
parent042b264c5591b430beca0c0acbdeec8c3d660525 (diff)
downloadredot-engine-27b7b433e03114c72c89397633d82fd67e0b0b8c.tar.gz
Fix Inspector may scrolls away when editing a property that adds or removes sub properties
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r--editor/editor_inspector.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 1e5acce032..7eb0732dbb 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -2766,8 +2766,9 @@ void EditorInspector::update_tree() {
// TODO: Can be useful to store more context for the focusable, such as the caret position in LineEdit.
StringName current_selected = property_selected;
int current_focusable = -1;
- // Temporarily disable focus following to avoid jumping while the inspector is updating.
- set_follow_focus(false);
+
+ // Temporarily disable focus following on the root inspector to avoid jumping while the inspector is updating.
+ get_root_inspector()->set_follow_focus(false);
if (property_focusable != -1) {
// Check that focusable is actually focusable.
@@ -2795,6 +2796,7 @@ void EditorInspector::update_tree() {
_clear(!object);
if (!object) {
+ get_root_inspector()->set_follow_focus(true);
return;
}
@@ -3532,7 +3534,8 @@ void EditorInspector::update_tree() {
// Updating inspector might invalidate some editing owners.
EditorNode::get_singleton()->hide_unused_editors();
}
- set_follow_focus(true);
+
+ get_root_inspector()->set_follow_focus(true);
}
void EditorInspector::update_property(const String &p_prop) {
@@ -3777,11 +3780,10 @@ void EditorInspector::set_use_wide_editors(bool p_enable) {
wide_editors = p_enable;
}
-void EditorInspector::set_sub_inspector(bool p_enable) {
- sub_inspector = p_enable;
- if (!is_inside_tree()) {
- return;
- }
+void EditorInspector::set_root_inspector(EditorInspector *p_root_inspector) {
+ root_inspector = p_root_inspector;
+ // Only the root inspector should follow focus.
+ set_follow_focus(false);
}
void EditorInspector::set_use_deletable_properties(bool p_enabled) {
@@ -4099,13 +4101,13 @@ void EditorInspector::_notification(int p_what) {
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed));
set_process(is_visible_in_tree());
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
- if (!sub_inspector) {
+ if (!is_sub_inspector()) {
get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
}
} break;
case NOTIFICATION_PREDELETE: {
- if (!sub_inspector && is_inside_tree()) {
+ if (!is_sub_inspector() && is_inside_tree()) {
get_tree()->disconnect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
}
edit(nullptr);
@@ -4164,7 +4166,7 @@ void EditorInspector::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
bool needs_update = false;
- if (EditorThemeManager::is_generated_theme_outdated() && !sub_inspector) {
+ if (!is_sub_inspector() && EditorThemeManager::is_generated_theme_outdated()) {
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
}