Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inspector jumping when gaining focus #101768

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion doc/classes/EditorInspector.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<members>
<member name="draw_focus_border" type="bool" setter="set_draw_focus_border" getter="get_draw_focus_border" overrides="ScrollContainer" default="true" />
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" />
<member name="follow_focus" type="bool" setter="set_follow_focus" getter="is_following_focus" overrides="ScrollContainer" default="true" />
<member name="horizontal_scroll_mode" type="int" setter="set_horizontal_scroll_mode" getter="get_horizontal_scroll_mode" overrides="ScrollContainer" enum="ScrollContainer.ScrollMode" default="0" />
</members>
<signals>
Expand Down
15 changes: 12 additions & 3 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2996,6 +2996,7 @@ void EditorInspector::update_tree() {
int current_focusable = -1;

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

if (property_focusable != -1) {
Expand Down Expand Up @@ -3024,7 +3025,7 @@ void EditorInspector::update_tree() {
_clear(!object);

if (!object) {
get_root_inspector()->set_follow_focus(true);
get_root_inspector()->set_follow_focus(was_following);
return;
}

Expand Down Expand Up @@ -3890,7 +3891,7 @@ void EditorInspector::update_tree() {
EditorNode::get_singleton()->hide_unused_editors();
}

get_root_inspector()->set_follow_focus(true);
get_root_inspector()->set_follow_focus(was_following);
}

void EditorInspector::update_property(const String &p_prop) {
Expand Down Expand Up @@ -4742,6 +4743,15 @@ void EditorInspector::_notification(int p_what) {
update_tree();
}
} break;

case NOTIFICATION_FOCUS_ENTER: {
set_follow_focus(true);
} break;

case NOTIFICATION_FOCUS_EXIT: {
// Don't follow focus when the inspector is not focused. Prevents potential jumping when gaining focus.
set_follow_focus(false);
} break;
}
}

Expand Down Expand Up @@ -4898,7 +4908,6 @@ EditorInspector::EditorInspector() {
base_vbox->add_child(main_vbox);

set_horizontal_scroll_mode(SCROLL_MODE_DISABLED);
set_follow_focus(true);

changing = 0;
search_box = nullptr;
Expand Down