2 extends DialogicVisualEditorField
4 ## Event block field for constant options. For varying options use ComplexPicker.
6 var options: Array = []
8 ## if true, only the symbol will be displayed. In the dropdown text will be visible.
9 ## Useful for making UI simpler
10 var symbol_only := false:
13 if value: self.text = ""
15 var current_value: Variant = -1
18 func _ready() -> void:
19 add_theme_color_override("font_disabled_color", get_theme_color("font_color", "MenuButton"))
20 self.about_to_popup.connect(insert_options)
21 call("get_popup").index_pressed.connect(index_pressed)
24 func _load_display_info(info:Dictionary) -> void:
25 options = info.get('options', [])
26 self.disabled = info.get('disabled', false)
27 symbol_only = info.get('symbol_only', false)
30 func _set_value(value:Variant) -> void:
31 for option in options:
32 if option['value'] == value:
33 if typeof(option.get('icon')) == TYPE_ARRAY:
34 option.icon = callv('get_theme_icon', option.get('icon'))
36 self.text = option['label']
37 self.icon = option.get('icon', null)
41 func get_value() -> Variant:
45 func insert_options() -> void:
46 call("get_popup").clear()
49 for option in options:
50 if typeof(option.get('icon')) == TYPE_ARRAY:
51 option.icon = callv('get_theme_icon', option.get('icon'))
52 call("get_popup").add_icon_item(option.get('icon', null), option['label'])
53 call("get_popup").set_item_metadata(idx, option['value'])
57 func index_pressed(idx:int) -> void:
60 self.text = call("get_popup").get_item_text(idx)
61 self.icon =call("get_popup").get_item_icon(idx)
62 value_changed.emit(property_name, call("get_popup").get_item_metadata(idx))