Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bucket of issues with OptionButton (Dropdown) #6558

Closed
ivanskodje opened this issue Sep 20, 2016 · 6 comments
Closed

A bucket of issues with OptionButton (Dropdown) #6558

ivanskodje opened this issue Sep 20, 2016 · 6 comments

Comments

@ivanskodje
Copy link
Contributor

ivanskodje commented Sep 20, 2016

(Godot build from 20.09.16)

Deleting Items

If you select an item and delete the same item, OptionButton does not change the selected text visible.
If you use the clear() function, selected id turns to -1 and there won't be any text visible; however, if you delete the last item without using clear(), selected item is still 0.

A possible solution, If you are deleting last item is to set selected id to -1

Another possibility would be to add an extra optional bool in remove_item() where false would be to return to the first item (if any) or -1 if it was the last item. True could be to move to the next item in selection (i.e. you delete ID 3, you select the new ID at 3).

Currently, when there are more items; simply deleting selected item will just


Selecting previously deleted ID

Currently when you try to select another item which have the same ID like the deleted item, it wont allow you to select it.

  1. Delete item#1 with ID 3
  2. Item#2 takes the place if ID3 after item#1 is gone
  3. Attempting to select item#2 does not work.

Adding an Item

After deleting the last item (having selected id at 0, problem with deletion), adding a new item does not automatically select the first item.

If you fix the problem with deletion, the selected_id should by default be -1 (when there are no previous item added) - which should automatically set selected to 0 when the first item is added.
(Of course you should not automatically select the LAST item if there are previous items available)


Cannot set selected to none

You are unable to set selected to -1 (none). You can use .select(id) to choose any existing ID, but we should definitely implement the option to set to -1 (none), which also is the same selected id you get when you use .clear().


OptionButton is a misleading name

Godot would benefit from renaming OptionButton to DropdownButton or something similar that gives you the perfect description of what it is. :)

@ivanskodje
Copy link
Contributor Author

Here is an OptionButton demo I made that should help you visualize the issues.
optionbutton_demo.zip

@neikeq
Copy link
Contributor

neikeq commented Sep 20, 2016

Referencing #3188 since this issue is related to the PopupMenu API which is likely to be refactored for 3.0. That issue does not mention your problems though.

@AlexHolly
Copy link
Contributor

Is there a reason why OptionButton.get_selected_id() returns always -1
I have to use OptionButton.selected

@tom-jk
Copy link

tom-jk commented Jul 24, 2020

Testing with a Godot 3-compatible remake of above demo: 6558_Demo2.zip

Testing on linux mint 18.3 with Godot 3.2.3.beta1

Deleting selected item does not update selection/text: still true
Deleting last item does not set selection=-1: still true
Selecting previously deleted ID: can't reproduce (maybe I misunderstand it)
New item unselected after deleting all (and selection=0): still true
Can't set selected to none (-1): still true
Get_selected_id() returns -1: not true (but returns 0 when selected=-1, though docs suggest this is intentional/known)

@akien-mga
Copy link
Member

Several of these listed issues have been fixed in #57330. It would be good to review the list and see what's left - possibly moving them to dedicated proposals or bug reports.

@KoBeWi
Copy link
Member

KoBeWi commented Mar 12, 2022

I checked all points and they seem to be resolved.
Here's the updated project from the 1st comment:
optionbuttontest.zip

@KoBeWi KoBeWi closed this as completed Mar 12, 2022
@KoBeWi KoBeWi added this to the 4.0 milestone Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants