Skip to content

Commit 84b66c7

Browse files
committed
Fix crash when clicking on underline property key
Fixes #226
1 parent 403cdc3 commit 84b66c7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

addons/pandora/ui/editor/property_editor/property_editor.gd

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var current_entity: PandoraEntity
2121

2222

2323
func _ready() -> void:
24-
property_bar.property_added.connect(_add_property)
24+
property_bar.property_added.connect(_add_property.bind(true))
2525
set_entity(null)
2626

2727

@@ -58,7 +58,9 @@ func set_entity(entity: PandoraEntity) -> void:
5858
_add_property_control(control, property)
5959

6060

61-
func _add_property(scene: PackedScene) -> void:
61+
# The focus parameter is optional, and only used to ask the editor to also focus to the
62+
# specified property
63+
func _add_property(scene: PackedScene, focus: bool = false) -> void:
6264
if not current_entity is PandoraCategory:
6365
print("Cannot add custom properties to non-categories!")
6466
return
@@ -69,10 +71,10 @@ func _add_property(scene: PackedScene) -> void:
6971
control.type
7072
)
7173
if property != null:
72-
_add_property_control(control, property)
74+
_add_property_control(control, property, focus)
7375

7476

75-
func _add_property_control(control: PandoraPropertyControl, property: PandoraProperty) -> void:
77+
func _add_property_control(control: PandoraPropertyControl, property: PandoraProperty, focus: bool = false) -> void:
7678
var control_kvp = PropertyControlKvp.instantiate()
7779
control.init(property)
7880
control_kvp.init(property, control, Pandora._entity_backend)
@@ -84,11 +86,12 @@ func _add_property_control(control: PandoraPropertyControl, property: PandoraPro
8486
property_list.add_child(control_kvp)
8587
control_kvp.property_key_edit.grab_focus()
8688
control_kvp.original_property_selected.connect(property_settings_container.set_property)
87-
await get_tree().process_frame
8889
# First scroll to the control node and then apply an offset.
8990
# It's important to wait a frame before scrolling as for the documentation.
90-
scroll_container.ensure_control_visible(control_kvp)
91-
scroll_container.scroll_vertical = scroll_container.scroll_vertical + 100
91+
if focus:
92+
await get_tree().process_frame
93+
scroll_container.ensure_control_visible(control_kvp)
94+
scroll_container.scroll_vertical = scroll_container.scroll_vertical + 100
9295

9396

9497
func _generate_property_name(type: String, entity: PandoraEntity) -> String:

0 commit comments

Comments
 (0)