-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Document using negative indices in OptionButton's set_item_*()
methods
#104131
base: master
Are you sure you want to change the base?
Document using negative indices in OptionButton's set_item_*()
methods
#104131
Conversation
This also adds a code sample that shuffles items in an OptionButton, which acts as a showcase for demonstrating programmatic usage.
e492fa2
to
e01432e
Compare
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.
Not a fan of the new example. It's very, very... specific and assumes a lot from the user.
The negative indices mention is a good thing. Although, as annoying as it would be, this information technically belongs to each individual method's description.
[b]Note:[/b] The ID values used for items are limited to 32 bits, not full 64 bits of [int]. This has a range of [code]-2^32[/code] to [code]2^32 - 1[/code], i.e. [code]-2147483648[/code] to [code]2147483647[/code]. | ||
[b]Note:[/b] The [member Button.text] and [member Button.icon] properties are set automatically based on the selected item. They shouldn't be changed manually. | ||
[b]Example:[/b] Shuffle all existing items in an OptionButton by programmatically getting the items, clearing the list and re-adding the items in a different order: |
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.
[b]Example:[/b] Shuffle all existing items in an OptionButton by programmatically getting the items, clearing the list and re-adding the items in a different order: | |
[b]Example:[/b] Shuffle all items in an [OptionButton] by fetching the items, clearing the list, and re-adding the items in a different order: |
@@ -6,8 +6,47 @@ | |||
<description> | |||
[OptionButton] is a type of button that brings up a dropdown with selectable items when pressed. The item selected becomes the "current" item and is displayed as the button text. | |||
See also [BaseButton] which contains common properties and methods associated with this node. | |||
Like [PopupMenu], all [code]set_item_*[/code] methods allow negative item indices, i.e. [code]-1[/code] to access the last item, [code]-2[/code] to select the second-to-last item, and so on. |
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.
Like [PopupMenu], all [code]set_item_*[/code] methods allow negative item indices, i.e. [code]-1[/code] to access the last item, [code]-2[/code] to select the second-to-last item, and so on. | |
Like [PopupMenu], all [code]set_item_*[/code] methods allow negative item indices. This means an index of [code]-1[/code] can be used to access the last item, [code]-2[/code] to access the second-to-last item, and so on. |
This also adds a code sample that shuffles items in an OptionButton, which acts as a showcase for demonstrating programmatic usage.