Documentation
¶
Overview ¶
Package OptionButton provides methods for working with OptionButton object instances.
Index ¶
- type Advanced
- type Any
- type Instance
- func (self Instance) AddIconItem(texture [1]gdclass.Texture2D, 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) GetItemIcon(idx int) [1]gdclass.Texture2D
- 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() [1]gdclass.PopupMenu
- func (self Instance) GetSelectableItem() int
- func (self Instance) GetSelectedId() int
- func (self Instance) GetSelectedMetadata() any
- func (self Instance) HasSelectableItems() bool
- func (self Instance) IsItemDisabled(idx int) bool
- func (self Instance) IsItemSeparator(idx int) bool
- func (self Instance) ItemCount() int
- func (self Instance) OnItemFocused(cb func(index int))
- func (self Instance) OnItemSelected(cb func(index int))
- 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) SetItemCount(value int)
- func (self Instance) SetItemDisabled(idx int, disabled bool)
- func (self Instance) SetItemIcon(idx int, texture [1]gdclass.Texture2D)
- 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) ShowPopup()
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Virtual(name string) reflect.Value
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 Instance ¶
type Instance [1]gdclass.OptionButton
[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. [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.
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 [param texture] icon, text [param label] and (optionally) [param id]. If no [param id] is passed, the item index will be used as the item's ID. New items are appended at the end.
func (Instance) AddItem ¶
Adds an item, with text [param label] and (optionally) [param id]. If no [param id] is passed, the item index will be used as the item's ID. New items are appended at the end.
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 [param 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) GetItemIcon ¶
Returns the icon of the item at index [param idx].
func (Instance) GetItemIndex ¶
Returns the index of the item with the given [param 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 [param idx].
func (Instance) GetItemTooltip ¶
Returns the tooltip of the item at index [param idx].
func (Instance) GetPopup ¶
Returns the [PopupMenu] contained in this button. [b]Warning:[/b] 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 [member Window.visible] property.
func (Instance) GetSelectableItem ¶
Returns the index of the first item which is not disabled, or marked as a separator. If [param from_last] is [code]true[/code], the items will be searched in reverse order. Returns [code]-1[/code] if no item is found.
func (Instance) GetSelectedId ¶
Returns the ID of the selected item, or [code]-1[/code] if no item is selected.
func (Instance) GetSelectedMetadata ¶
Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata].
func (Instance) HasSelectableItems ¶
Returns [code]true[/code] if this button contains at least one item which is not disabled, or marked as a separator.
func (Instance) IsItemDisabled ¶
Returns [code]true[/code] if the item at index [param idx] is disabled.
func (Instance) IsItemSeparator ¶
Returns [code]true[/code] if the item at index [param idx] is marked as a separator.
func (Instance) OnItemFocused ¶
func (Instance) OnItemSelected ¶
func (Instance) RemoveItem ¶
Removes the item at index [param 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 [code]-1[/code] as the index deselects any currently selected item.
func (Instance) SetAllowReselect ¶
func (Instance) SetDisableShortcuts ¶
If [code]true[/code], shortcuts are disabled and cannot be used to trigger the button.
func (Instance) SetFitToLongestItem ¶
func (Instance) SetItemCount ¶
func (Instance) SetItemDisabled ¶
Sets whether the item at index [param 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 [param 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 [param idx].
func (Instance) SetItemTooltip ¶
Sets the tooltip of the item at index [param idx].
func (Instance) ShowPopup ¶
func (self Instance) ShowPopup()
Adjusts popup position and sizing for the [OptionButton], then shows the [PopupMenu]. Prefer this over using [code]get_popup().popup()[/code].