-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Make various improvements to OptionButton #57330
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aekobear
changed the title
Fix various OptionButton selection bugs
Fix various OptionButton improvements
Jan 27, 2022
aekobear
changed the title
Fix various OptionButton improvements
Make various improvements to OptionButton
Jan 27, 2022
akien-mga
reviewed
Jan 28, 2022
akien-mga
approved these changes
Jan 28, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I think it would be worth mentioning the new behavior in the select
docs too:
Passing `[code]-1[/code]` as index deselects any currently selected item.
- Allow OptionButton selection to be set to -1 to signify no selection, both via API and in the editor. - Reset OptionButton selection to -1 when the selected item has been removed. - Fully convert PopupMenu to a zero-based ID system, which improves an inconsistency in generated IDs when making new items in the editor.
Good point- updated |
Thanks! And congrats for your first merged Godot contribution 🎉 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed several bugs from #6558
optionButton.select(-1)
Selected
property in the editor can now be set to-1
for no selectionSelected
property can now be restored to default (which is -1)I also found an undocumented bug introduced here: #54647
The PopupMenu had been edited to use IDs starting at 0 in some places, but in other places (and in OptionButton) it was expected to use IDs starting at 1. This caused a bug where when adding OptionButton items from the inspector, both of the first two items would have ID = 1
Rather than reverting, I fully converted PopupMenu and OptionButton to use 0-based IDs. This matches the documentation, which claims that IDs are set by index (which starts with 0). It also improves some dissonance where "0" could be passed in as a valid object ID but was also being used to represent "no selection" when calling
get_selected_id()
. Now, -1 represent no selection in both the index and the ID flows.