diff options
Diffstat (limited to 'option_set/option_set.gd')
| -rw-r--r-- | option_set/option_set.gd | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/option_set/option_set.gd b/option_set/option_set.gd deleted file mode 100644 index 25ca0ff..0000000 --- a/option_set/option_set.gd +++ /dev/null @@ -1,44 +0,0 @@ -extends Control -class_name OptionSet - -export var placeholder: String - -var text: String setget set_text, get_text - -func set_text(var value: String): - input.text = value - -func get_text() -> String: - return input.text - -var selected_idx: int - -onready var input := get_node("input") as LineEdit -onready var button := get_node("button") as Button -onready var popup := get_node("/root/main/popup") as ModalPopup -onready var options := get_node("/root/main/option_set_list") as OptionSetList - - -func _ready(): - assert(popup != null, "OptionSet failed to get 'popup' node.") - input.placeholder_text = placeholder - input.connect("focus_entered", input, "set", ["caret_position", input.max_length]) - input.connect("focus_exited", input, "deselect") - - -func show_options(options_array: Array): - options.clear_items() - options.add_items(options_array) - 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): - if index != -1: - selected_idx = index - input.text = text - input.caret_position = input.max_length - popup.close_popup() - - |
