From 8491abc4805cee3b2dfb74817ef8908df085c5cf Mon Sep 17 00:00:00 2001 From: dam Date: Fri, 1 Apr 2022 11:32:45 +0000 Subject: Option set changed to work with empty list instead of creating dummy -- entry. --- option_set/option_set.gd | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'option_set/option_set.gd') diff --git a/option_set/option_set.gd b/option_set/option_set.gd index 0e8f90e..bb37736 100644 --- a/option_set/option_set.gd +++ b/option_set/option_set.gd @@ -29,19 +29,16 @@ func _ready(): func show_options(options_array: Array): options.clear_items() options.add_items(options_array) - if options_array[selected_idx] == input.text: - options.select(selected_idx) - else: - options.unselect() - options.connect("item_selected", self, "popup_result", []) - options.connect("nothing_selected", self, "popup_result", [-1, ""]) + options.select(options_array.find(input.text)) + options.connect("selection_changed", self, "popup_result") popup.open_popup(input.placeholder_text, options) func popup_result(index: int, text: String): - selected_idx = index - input.text = text - input.caret_position = input.max_length + if index != -1: + selected_idx = index + input.text = text + input.caret_position = input.max_length popup.close_popup() -- cgit v1.2.3