aboutsummaryrefslogtreecommitdiff
path: root/option_set/option_set.gd
diff options
context:
space:
mode:
Diffstat (limited to 'option_set/option_set.gd')
-rw-r--r--option_set/option_set.gd15
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()