extends Control class_name OptionSet var options: Array var text: String setget set_text, get_text func set_text(var value: String): input.text = value func get_text() -> String: return input.text onready var input := get_node("input") as LineEdit onready var button := get_node("options") as Button # @DAM Maybe rename this. Also requires renaming on stage. onready var popup := get_node("/root/main/popup_list") as PopupList func _ready(): assert(popup != null, "OptionSet failed to get 'popup' node.") input.connect("focus_entered", input, "set", ["caret_position", input.max_length]) input.connect("focus_exited", input, "deselect") func show_options(options_array: Array): options = options_array popup.connect("item_selected", self, "option_selected", [], CONNECT_ONESHOT) popup.popup_options(options) func option_selected(index: int): if index >= 0 && index < options.size(): input.text = options[index] input.caret_position = input.max_length button.release_focus()