Documentation
¶
Overview ¶
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.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- func (self *Extension[T]) AsBaseButton() BaseButton.Instance
- func (self *Extension[T]) AsButton() Button.Instance
- func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
- func (self *Extension[T]) AsControl() Control.Instance
- func (self *Extension[T]) AsNode() Node.Instance
- func (self *Extension[T]) AsObject() [1]gd.Object
- func (self *Extension[T]) AsOptionButton() Instance
- type ID
- type Instance
- func (self Instance) AddIconItem(texture Texture2D.Instance, label string)
- func (self Instance) AddItem(label string)
- func (self Instance) AddSeparator()
- func (self Instance) AllowReselect() bool
- func (self Instance) AsBaseButton() BaseButton.Instance
- func (self Instance) AsButton() Button.Instance
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsControl() Control.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsOptionButton() Instance
- func (self Instance) Clear()
- func (self Instance) FitToLongestItem() bool
- func (self Instance) GetItemAutoTranslateMode(idx int) Node.AutoTranslateMode
- func (self Instance) GetItemIcon(idx int) Texture2D.Instance
- func (self Instance) GetItemId(idx int) int
- func (self Instance) GetItemIndex(id int) int
- func (self Instance) GetItemMetadata(idx int) any
- func (self Instance) GetItemText(idx int) string
- func (self Instance) GetItemTooltip(idx int) string
- func (self Instance) GetPopup() PopupMenu.Instance
- func (self Instance) GetSelectableItem() int
- func (self Instance) GetSelectedId() int
- func (self Instance) GetSelectedMetadata() any
- func (self Instance) HasSelectableItems() bool
- func (self Instance) ID() ID
- func (self Instance) IsItemDisabled(idx int) bool
- func (self Instance) IsItemSeparator(idx int) bool
- func (self Instance) ItemCount() int
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) OnItemFocused(cb func(index int), flags ...Signal.Flags)
- func (self Instance) OnItemSelected(cb func(index int), flags ...Signal.Flags)
- func (self Instance) RemoveItem(idx int)
- func (self Instance) Select(idx int)
- func (self Instance) Selected() int
- func (self Instance) SetAllowReselect(value bool)
- func (self Instance) SetDisableShortcuts(disabled bool)
- func (self Instance) SetFitToLongestItem(value bool)
- func (self Instance) SetItemAutoTranslateMode(idx int, mode Node.AutoTranslateMode)
- func (self Instance) SetItemCount(value int)
- func (self Instance) SetItemDisabled(idx int, disabled bool)
- func (self Instance) SetItemIcon(idx int, texture Texture2D.Instance)
- func (self Instance) SetItemId(idx int, id int)
- func (self Instance) SetItemMetadata(idx int, metadata any)
- func (self Instance) SetItemText(idx int, text string)
- func (self Instance) SetItemTooltip(idx int, tooltip string)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) ShowPopup()
- func (self Instance) Virtual(name string) reflect.Value
- type MoreArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsBaseButton ¶
func (self *Extension[T]) AsBaseButton() BaseButton.Instance
func (*Extension[T]) AsCanvasItem ¶
func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
func (*Extension[T]) AsOptionButton ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.OptionButton
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AddIconItem ¶
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.
func (Instance) AddItem ¶
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.
func (Instance) AddSeparator ¶
func (self Instance) AddSeparator()
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.
func (Instance) AllowReselect ¶
func (Instance) AsBaseButton ¶
func (self Instance) AsBaseButton() BaseButton.Instance
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AsOptionButton ¶
func (Instance) FitToLongestItem ¶
func (Instance) GetItemAutoTranslateMode ¶
func (self Instance) GetItemAutoTranslateMode(idx int) Node.AutoTranslateMode
Returns the auto translate mode of the item at index 'idx'.
func (Instance) GetItemIcon ¶
Returns the icon of the item at index 'idx'.
func (Instance) GetItemIndex ¶
Returns the index of the item with the given 'id'.
func (Instance) GetItemMetadata ¶
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.
func (Instance) GetItemText ¶
Returns the text of the item at index 'idx'.
func (Instance) GetItemTooltip ¶
Returns the tooltip of the item at index 'idx'.
func (Instance) GetPopup ¶
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.
func (Instance) GetSelectableItem ¶
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.
func (Instance) GetSelectedId ¶
Returns the ID of the selected item, or -1 if no item is selected.
func (Instance) GetSelectedMetadata ¶
Gets the metadata of the selected item. Metadata for items can be set using SetItemMetadata.
func (Instance) HasSelectableItems ¶
Returns true if this button contains at least one item which is not disabled, or marked as a separator.
func (Instance) IsItemDisabled ¶
Returns true if the item at index 'idx' is disabled.
func (Instance) IsItemSeparator ¶
Returns true if the item at index 'idx' is marked as a separator.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) OnItemFocused ¶
func (Instance) OnItemSelected ¶
func (Instance) RemoveItem ¶
Removes the item at index 'idx'.
func (Instance) Select ¶
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.
func (Instance) SetAllowReselect ¶
func (Instance) SetDisableShortcuts ¶
If true, shortcuts are disabled and cannot be used to trigger the button.
func (Instance) SetFitToLongestItem ¶
func (Instance) SetItemAutoTranslateMode ¶
func (self Instance) SetItemAutoTranslateMode(idx int, mode Node.AutoTranslateMode)
Sets the auto translate mode of the item at index 'idx'.
Items use [Node.AutoTranslateModeInherit] by default, which uses the same auto translate mode as the OptionButton itself.
func (Instance) SetItemCount ¶
func (Instance) SetItemDisabled ¶
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.
func (Instance) SetItemIcon ¶
Sets the icon of the item at index 'idx'.
func (Instance) SetItemMetadata ¶
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.
func (Instance) SetItemText ¶
Sets the text of the item at index 'idx'.
func (Instance) SetItemTooltip ¶
Sets the tooltip of the item at index 'idx'.
func (Instance) ShowPopup ¶
func (self Instance) ShowPopup()
Adjusts popup position and sizing for the OptionButton, then shows the PopupMenu. Prefer this over using get_popup().popup().
type MoreArgs ¶
type MoreArgs [1]gdclass.OptionButton
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) AddIconItem ¶
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.
func (MoreArgs) AddItem ¶
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.
func (MoreArgs) AddSeparator ¶
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.
func (MoreArgs) GetSelectableItem ¶
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.