Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
OptionButton¶
Inherits: Button < BaseButton < Control < CanvasItem < Node < Object
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 ID values used for items are limited to 32 bits, not full 64 bits of int. This has a range of -2^32
to 2^32 - 1
, i.e. -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.
属性¶
action_mode |
|
|
alignment |
|
|
|
||
|
||
|
||
|
||
toggle_mode |
|
Methods¶
void |
add_icon_item ( Texture2D texture, String label, int id=-1 ) |
void |
|
void |
add_separator ( String text="" ) |
void |
clear ( ) |
get_item_icon ( int idx ) const |
|
get_item_id ( int idx ) const |
|
get_item_index ( int id ) const |
|
get_item_metadata ( int idx ) const |
|
get_item_text ( int idx ) const |
|
get_item_tooltip ( int idx ) const |
|
get_popup ( ) const |
|
get_selectable_item ( bool from_last=false ) const |
|
get_selected_id ( ) const |
|
get_selected_metadata ( ) const |
|
has_selectable_items ( ) const |
|
is_item_disabled ( int idx ) const |
|
is_item_separator ( int idx ) const |
|
void |
remove_item ( int idx ) |
void |
|
void |
set_disable_shortcuts ( bool disabled ) |
void |
set_item_disabled ( int idx, bool disabled ) |
void |
set_item_icon ( int idx, Texture2D texture ) |
void |
set_item_id ( int idx, int id ) |
void |
set_item_metadata ( int idx, Variant metadata ) |
void |
set_item_text ( int idx, String text ) |
void |
set_item_tooltip ( int idx, String tooltip ) |
void |
show_popup ( ) |
Theme Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
信号¶
item_focused ( int index )
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 selected is passed as argument.
item_selected ( int index )
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.
Property Descriptions¶
bool allow_reselect = false
If true
, the currently selected item can be selected again.
bool fit_to_longest_item = true