aboutsummaryrefslogtreecommitdiff
path: root/option_set/option_set.gd
diff options
context:
space:
mode:
authordam <dam@gudinoff>2022-03-30 16:37:28 +0000
committerdam <dam@gudinoff>2022-03-30 16:37:28 +0000
commite04f33a614e2723db47f69a7f3146b030ee5e326 (patch)
tree999dd486901a363e4f1b427117de0e120eb465b4 /option_set/option_set.gd
parent8d4db7d2c92aa719da8ce218df9490283754d20b (diff)
downloadsurgery-log-e04f33a614e2723db47f69a7f3146b030ee5e326.tar.zst
surgery-log-e04f33a614e2723db47f69a7f3146b030ee5e326.zip
Add dismiss button logic on popup.
Diffstat (limited to 'option_set/option_set.gd')
-rw-r--r--option_set/option_set.gd24
1 files changed, 9 insertions, 15 deletions
diff --git a/option_set/option_set.gd b/option_set/option_set.gd
index 2ac1475..637d033 100644
--- a/option_set/option_set.gd
+++ b/option_set/option_set.gd
@@ -28,30 +28,24 @@ func _ready():
func show_options(options_array: Array):
options.clear_items()
- var main = get_node("/root/main")
- main.remove_child(options)
options.add_items(options_array)
if options_array[selected_idx] == input.text:
options.select(selected_idx)
else:
options.unselect()
- options.connect("item_selected", self, "option_selected", [], CONNECT_ONESHOT)
- popup.popup_control(input.placeholder_text, options)
-# popup.connect("item_selected", self, "option_selected", [], CONNECT_ONESHOT)
-# popup.clear_items()
-# popup_opt.visible = true
-# get_node("/root/main/popup/blur")
-# popup.add_items(options)
+ options.connect("item_selected", self, "popup_result", [])
+ options.connect("nothing_selected", self, "popup_result", [-1, ""])
+ popup.connect("dismissed", self, "popup_result", [selected_idx, input.text])
+ popup.open_popup(input.placeholder_text, options)
-func option_selected(index: int, text: String):
+func popup_result(index: int, text: String):
+ options.disconnect("item_selected", self, "popup_result")
+ options.disconnect("nothing_selected", self, "popup_result")
+ popup.disconnect("dismissed", self, "popup_result")
selected_idx = index
input.text = text
input.caret_position = input.max_length
- button.release_focus()
- options.visible = false
- var main = get_node("/root/main")
- main.add_child(options)
-
+ popup.close_popup()