Skip to content

Commit

Permalink
Add auto-scroll to new properties (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
shomykohai authored Sep 18, 2024
1 parent 0ab49fb commit a92bb2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/pandora/ui/editor/property_editor/property_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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_kvp)
scroll_container.scroll_vertical = scroll_container.scroll_vertical + 100


func _generate_property_name(type: String, entity: PandoraEntity) -> String:
Expand Down
2 changes: 2 additions & 0 deletions addons/pandora/ui/editor/property_editor/property_editor.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ visible = false
layout_mode = 2

[node name="ScrollContainer" type="ScrollContainer" parent="PropertyContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
follow_focus = true

[node name="VBoxContainer" type="VBoxContainer" parent="PropertyContainer/ScrollContainer"]
layout_mode = 2
Expand Down

0 comments on commit a92bb2f

Please sign in to comment.