Skip to content

Commit 998a217

Browse files
committed
Merge pull request godotengine#101768 from KoBeWi/just_spread_the_code_with_another_layer_of_hacks_what_can_go_wrong_huh
Fix inspector jumping when gaining focus
2 parents d571eea + 9226424 commit 998a217

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

doc/classes/EditorInspector.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
<members>
5252
<member name="draw_focus_border" type="bool" setter="set_draw_focus_border" getter="get_draw_focus_border" overrides="ScrollContainer" default="true" />
5353
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" />
54-
<member name="follow_focus" type="bool" setter="set_follow_focus" getter="is_following_focus" overrides="ScrollContainer" default="true" />
5554
<member name="horizontal_scroll_mode" type="int" setter="set_horizontal_scroll_mode" getter="get_horizontal_scroll_mode" overrides="ScrollContainer" enum="ScrollContainer.ScrollMode" default="0" />
5655
</members>
5756
<signals>

editor/editor_inspector.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,6 +2996,7 @@ void EditorInspector::update_tree() {
29962996
int current_focusable = -1;
29972997

29982998
// Temporarily disable focus following on the root inspector to avoid jumping while the inspector is updating.
2999+
bool was_following = get_root_inspector()->is_following_focus();
29993000
get_root_inspector()->set_follow_focus(false);
30003001

30013002
if (property_focusable != -1) {
@@ -3024,7 +3025,7 @@ void EditorInspector::update_tree() {
30243025
_clear(!object);
30253026

30263027
if (!object) {
3027-
get_root_inspector()->set_follow_focus(true);
3028+
get_root_inspector()->set_follow_focus(was_following);
30283029
return;
30293030
}
30303031

@@ -3890,7 +3891,7 @@ void EditorInspector::update_tree() {
38903891
EditorNode::get_singleton()->hide_unused_editors();
38913892
}
38923893

3893-
get_root_inspector()->set_follow_focus(true);
3894+
get_root_inspector()->set_follow_focus(was_following);
38943895
}
38953896

38963897
void EditorInspector::update_property(const String &p_prop) {
@@ -4742,6 +4743,15 @@ void EditorInspector::_notification(int p_what) {
47424743
update_tree();
47434744
}
47444745
} break;
4746+
4747+
case NOTIFICATION_FOCUS_ENTER: {
4748+
set_follow_focus(true);
4749+
} break;
4750+
4751+
case NOTIFICATION_FOCUS_EXIT: {
4752+
// Don't follow focus when the inspector is not focused. Prevents potential jumping when gaining focus.
4753+
set_follow_focus(false);
4754+
} break;
47454755
}
47464756
}
47474757

@@ -4898,7 +4908,6 @@ EditorInspector::EditorInspector() {
48984908
base_vbox->add_child(main_vbox);
48994909

49004910
set_horizontal_scroll_mode(SCROLL_MODE_DISABLED);
4901-
set_follow_focus(true);
49024911

49034912
changing = 0;
49044913
search_box = nullptr;

0 commit comments

Comments
 (0)