From 656bc169b01cc54e57139b5f2c39f6ba69cc7380 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sun, 28 Jan 2024 22:25:31 +0100 Subject: [PATCH] Editor: Scroll to focus when adding a var in Blackboard Plan editor --- editor/blackboard_plan_editor.cpp | 3 +++ util/limbo_string_names.cpp | 2 ++ util/limbo_string_names.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/editor/blackboard_plan_editor.cpp b/editor/blackboard_plan_editor.cpp index 0eccaa5..f02f6f7 100644 --- a/editor/blackboard_plan_editor.cpp +++ b/editor/blackboard_plan_editor.cpp @@ -171,6 +171,9 @@ void BlackboardPlanEditor::_add_var_pressed() { LineEdit *name_edit = _get_name_edit(rows_vbox->get_child_count() - 1); name_edit->grab_focus(); name_edit->select_all(); + + // Note: Scroll to the end, delay is necessary here. + scroll_container->call_deferred(LW_NAME(call_deferred), LW_NAME(set_v_scroll), 888888888); } void BlackboardPlanEditor::_drag_button_down(Control *p_row) { diff --git a/util/limbo_string_names.cpp b/util/limbo_string_names.cpp index bbc426f..80b8596 100644 --- a/util/limbo_string_names.cpp +++ b/util/limbo_string_names.cpp @@ -55,6 +55,7 @@ LimboStringNames::LimboStringNames() { BTAlwaysSucceed = SN("BTAlwaysSucceed"); button_down = SN("button_down"); button_up = SN("button_up"); + call_deferred = SN("call_deferred"); changed = SN("changed"); connect = SN("connect"); dark_color_1 = SN("dark_color_1"); @@ -130,6 +131,7 @@ LimboStringNames::LimboStringNames() { separation = SN("separation"); set_custom_name = SN("set_custom_name"); set_root_task = SN("set_root_task"); + set_v_scroll = SN("set_v_scroll"); setup = SN("setup"); started = SN("started"); state_changed = SN("state_changed"); diff --git a/util/limbo_string_names.h b/util/limbo_string_names.h index d06e02d..f3188f9 100644 --- a/util/limbo_string_names.h +++ b/util/limbo_string_names.h @@ -69,6 +69,7 @@ public: StringName BTAlwaysSucceed; StringName button_down; StringName button_up; + StringName call_deferred; StringName changed; StringName connect; StringName dark_color_1; @@ -145,6 +146,7 @@ public: StringName separation; StringName set_custom_name; StringName set_root_task; + StringName set_v_scroll; StringName setup; StringName started; StringName state_changed;