Skip to content

Commit 59f7c04

Browse files
committed
ParameterInput: Add current value to options list
If the current value is not already in the options list, add it to the list. https://phabricator.endlessm.com/T35564
1 parent baf52cc commit 59f7c04

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ func _update_option_input(current_value: Variant = null):
241241
if item == current_value:
242242
selected_item_index = item_index
243243

244+
if selected_item_index == -1 and current_value:
245+
# If the current value is not in the default list of options, add it
246+
# and select it.
247+
_option_input.add_separator()
248+
var item_index = _option_input.item_count
249+
var option_label = current_value.capitalize()
250+
_option_input.add_item(option_label)
251+
_option_input.set_item_metadata(item_index, current_value)
252+
selected_item_index = item_index
253+
elif selected_item_index == -1:
254+
selected_item_index = option_data.selected
255+
244256
_option_input.select(selected_item_index)
245257

246258

0 commit comments

Comments
 (0)