diff options
| author | dam <dam@gudinoff> | 2022-04-01 11:32:45 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2022-04-01 11:32:45 +0000 |
| commit | 8491abc4805cee3b2dfb74817ef8908df085c5cf (patch) | |
| tree | 041687da080004a8d105ce1c451f972b4d1df0c6 /option_set/option_set.gd | |
| parent | 9b619b8c5f117e53b121c2d868b024c7c7d08f4c (diff) | |
| download | surgery-log-8491abc4805cee3b2dfb74817ef8908df085c5cf.tar.zst surgery-log-8491abc4805cee3b2dfb74817ef8908df085c5cf.zip | |
Option set changed to work with empty list instead of creating dummy -- entry.
Diffstat (limited to 'option_set/option_set.gd')
| -rw-r--r-- | option_set/option_set.gd | 15 |
1 files changed, 6 insertions, 9 deletions
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() |
