From 0239828bd53c96696d2ca6274704323e5c24e1c4 Mon Sep 17 00:00:00 2001 From: Shomy <61943525+shomykohai@users.noreply.github.com> Date: Wed, 18 Sep 2024 03:03:28 +0200 Subject: [PATCH] Add auto-scroll to new property --- .../pandora/ui/editor/property_editor/property_editor.gd | 7 +++++++ .../pandora/ui/editor/property_editor/property_editor.tscn | 1 + 2 files changed, 8 insertions(+) diff --git a/addons/pandora/ui/editor/property_editor/property_editor.gd b/addons/pandora/ui/editor/property_editor/property_editor.gd index 6a07de4a..95ca0573 100644 --- a/addons/pandora/ui/editor/property_editor/property_editor.gd +++ b/addons/pandora/ui/editor/property_editor/property_editor.gd @@ -15,6 +15,7 @@ const PROPERTY_DEFAULT_NAME = "property" @onready var unselected_container = %UnselectedContainer @onready var entity_attributes = %EntityAttributes @onready var property_settings_container = %PropertySettingsContainer +@onready var scroll_container: ScrollContainer = %ScrollContainer var current_entity: PandoraEntity @@ -81,7 +82,13 @@ func _add_property_control(control: PandoraPropertyControl, property: PandoraPro ) ) property_list.add_child(control_kvp) + control_kvp.property_key_edit.grab_focus() control_kvp.original_property_selected.connect(property_settings_container.set_property) + await get_tree().process_frame + # First scroll to the control node and then apply an offset. + # It's important to wait a frame before scrolling as for the documentation. + scroll_container.ensure_control_visible(control) + scroll_container.scroll_vertical = scroll_container.scroll_vertical + 100 func _generate_property_name(type: String, entity: PandoraEntity) -> String: diff --git a/addons/pandora/ui/editor/property_editor/property_editor.tscn b/addons/pandora/ui/editor/property_editor/property_editor.tscn index a09c774b..e4c8926c 100644 --- a/addons/pandora/ui/editor/property_editor/property_editor.tscn +++ b/addons/pandora/ui/editor/property_editor/property_editor.tscn @@ -45,6 +45,7 @@ layout_mode = 2 [node name="ScrollContainer" type="ScrollContainer" parent="PropertyContainer"] layout_mode = 2 size_flags_vertical = 3 +follow_focus = true [node name="VBoxContainer" type="VBoxContainer" parent="PropertyContainer/ScrollContainer"] layout_mode = 2