A button that brings up a dropdown with selectable options when pressed.
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.
Note: The IDs used for items are limited to signed 32-bit integers, not the full 64 bits of int. These have a range of -2^31 to 2^31 - 1, that is, -2147483648 to 2147483647.
Note: The Button.text and Button.icon properties are set automatically based on the selected item. They shouldn't be changed manually.
If true, minimum size will be determined by the longest item's width, instead of the currently selected one's. It will also take the popup's margins into account, making the button match its total width.
Note: For performance reasons, the minimum size doesn't update immediately when adding, removing or modifying items.
If true, shows a search bar at the top of the PopupMenu for filtering items. See search_bar_min_item_count for dynamically controlling its visibility based on the number of items.
If true, enables fuzzy searching in the PopupMenu search bar. This allows the search results to include items that almost match the search query, as well items that match the individual characters of the search query, but not in sequence.
Use search_bar_fuzzy_search_max_misses to set the maximum number of mismatches allowed in the search results.
Sets the maximum number of mismatches allowed in each search result when fuzzy searching is enabled for the PopupMenu search bar. Any item with more mismatches will be hidden from the search results.
Sets the minimum number of items required for the PopupMenu search bar to be visible. search_bar_enabled must be true for this to have any effect.
Adds an item, with a texture icon, text label and (optionally) id. If no id is passed, the item index will be used as the item's ID. New items are appended at the end.
Note: The item will be selected if there are no other items.
Adds an item, with text label and (optionally) id. If no id is passed, the item index will be used as the item's ID. New items are appended at the end.
Note: The item will be selected if there are no other items.
Adds a separator to the list of items. Separators help to group items, and can optionally be given a text header. A separator also gets an index assigned, and is appended at the end of the item list.
Retrieves the metadata of an item. Metadata may be any type and can be used to store extra information about an item, such as an external string ID.
Returns the PopupMenu contained in this button.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their Window.visible property.
Returns the index of the first item which is not disabled, or marked as a separator. If from_last is true, the items will be searched in reverse order.
Returns -1 if no item is found.
Gets the metadata of the selected item. Metadata for items can be set using set_item_metadata().
Returns true if this button contains at least one item which is not disabled, or marked as a separator.
Selects an item by index and makes it the current item. This will work even if the item is disabled.
Passing -1 as the index deselects any currently selected item.
Sets the auto translate mode of the item at index idx.
Items use Node.AUTO_TRANSLATE_MODE_INHERIT by default, which uses the same auto translate mode as the OptionButton itself.
Sets whether the item at index idx is disabled.
Disabled items are drawn differently in the dropdown and are not selectable by the user. If the current selected item is set as disabled, it will remain selected.
Sets the metadata of an item. Metadata may be of any type and can be used to store extra information about an item, such as an external string ID.
Adjusts popup position and sizing for the OptionButton, then shows the PopupMenu. Prefer this over using get_popup().popup().
Emitted when the user navigates to an item using the ProjectSettings.input/ui_up or ProjectSettings.input/ui_down input actions. The index of the item focused is passed as argument.
Emitted when the current item has been changed by the user. The index of the item selected is passed as argument.
allow_reselect must be enabled to reselect an item.