You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to sort items of a OptionButton by their text but $OptionButton.items.sort() didn't do anything as far as I could find out. They are also not sorted by their Id.
Steps to reproduce:
Create a scene with root node OptionButton. Add Items to it and put some text in each in an alphabetically unsorted order. Attach a script to it. In _ready():
type items.sort()
Start the scene. OptionButton items sort bug.zip
Minimal reproduction project:
The text was updated successfully, but these errors were encountered:
MaaaxiKing
changed the title
Cannot sort Optionbutton's items be their text alphabetically
Cannot sort Optionbutton's items by their text and Id alphabetically
Jun 6, 2020
At the moment you have to add the items in the order you want them to be in. So you have to clear and refill the items whenever you want to sort them in a different way.
ItemList has a very similar API to the OptionButton but also a sort_items_by_text() function. I think if ItemList has such a function so should the OptionButton.
Would it make sense to add other functions of the ItemList that are missing on the button? Their backends are probably quite different but from the user perspective the APIs seem very similar but OptionButton is missing quite a bit of functionality that the ItemList has.
I think get_item_icon(), get_item_id(), get_item_index(), get_item_metadata(), get_item_text() should be removed and their should be get_item(). You could get the item by maybe doing get_item(text="this_item_text_is_hello") or get_item(id=1) etc. and on this that you should be able to call icon, id, index, metadata. On .items you should be able to call count, so get_item_count( ) would be unnecessary.
Godot version:
3.2.1.stableOS/device including version:
Windows 10 Home 1909Issue description:
I wanted to sort items of a OptionButton by their text but $OptionButton.items.sort() didn't do anything as far as I could find out. They are also not sorted by their Id.Steps to reproduce:
Create a scene with root node OptionButton. Add Items to it and put some text in each in an alphabetically unsorted order. Attach a script to it. In
_ready():
type
items.sort()
Start the scene.
OptionButton items sort bug.zip
Minimal reproduction project:
The text was updated successfully, but these errors were encountered: