OptionButton

package
v0.0.0-...-f3deeb4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package OptionButton provides methods for working with OptionButton object instances.

Index

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 Any

type Any interface {
	gd.IsClass
	AsOptionButton() Instance
}

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 New

func New() Instance

func (Instance) AddIconItem

func (self Instance) AddIconItem(texture [1]gdclass.Texture2D, label string)

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

func (self Instance) AddItem(label string)

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 (self Instance) AllowReselect() bool

func (Instance) AsBaseButton

func (self Instance) AsBaseButton() BaseButton.Instance

func (Instance) AsButton

func (self Instance) AsButton() Button.Instance

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsControl

func (self Instance) AsControl() Control.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsOptionButton

func (self Instance) AsOptionButton() Instance

func (Instance) Clear

func (self Instance) Clear()

Clears all the items in the [OptionButton].

func (Instance) FitToLongestItem

func (self Instance) FitToLongestItem() bool

func (Instance) GetItemIcon

func (self Instance) GetItemIcon(idx int) [1]gdclass.Texture2D

Returns the icon of the item at index [param idx].

func (Instance) GetItemId

func (self Instance) GetItemId(idx int) int

Returns the ID of the item at index [param idx].

func (Instance) GetItemIndex

func (self Instance) GetItemIndex(id int) int

Returns the index of the item with the given [param id].

func (Instance) GetItemMetadata

func (self Instance) GetItemMetadata(idx int) any

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

func (self Instance) GetItemText(idx int) string

Returns the text of the item at index [param idx].

func (Instance) GetItemTooltip

func (self Instance) GetItemTooltip(idx int) string

Returns the tooltip of the item at index [param idx].

func (Instance) GetPopup

func (self Instance) GetPopup() [1]gdclass.PopupMenu

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

func (self Instance) GetSelectableItem() int

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

func (self Instance) GetSelectedId() int

Returns the ID of the selected item, or [code]-1[/code] if no item is selected.

func (Instance) GetSelectedMetadata

func (self Instance) GetSelectedMetadata() any

Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata].

func (Instance) HasSelectableItems

func (self Instance) HasSelectableItems() bool

Returns [code]true[/code] if this button contains at least one item which is not disabled, or marked as a separator.

func (Instance) IsItemDisabled

func (self Instance) IsItemDisabled(idx int) bool

Returns [code]true[/code] if the item at index [param idx] is disabled.

func (Instance) IsItemSeparator

func (self Instance) IsItemSeparator(idx int) bool

Returns [code]true[/code] if the item at index [param idx] is marked as a separator.

func (Instance) ItemCount

func (self Instance) ItemCount() int

func (Instance) OnItemFocused

func (self Instance) OnItemFocused(cb func(index int))

func (Instance) OnItemSelected

func (self Instance) OnItemSelected(cb func(index int))

func (Instance) RemoveItem

func (self Instance) RemoveItem(idx int)

Removes the item at index [param idx].

func (Instance) Select

func (self Instance) Select(idx int)

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) Selected

func (self Instance) Selected() int

func (Instance) SetAllowReselect

func (self Instance) SetAllowReselect(value bool)

func (Instance) SetDisableShortcuts

func (self Instance) SetDisableShortcuts(disabled bool)

If [code]true[/code], shortcuts are disabled and cannot be used to trigger the button.

func (Instance) SetFitToLongestItem

func (self Instance) SetFitToLongestItem(value bool)

func (Instance) SetItemCount

func (self Instance) SetItemCount(value int)

func (Instance) SetItemDisabled

func (self Instance) SetItemDisabled(idx int, disabled bool)

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

func (self Instance) SetItemIcon(idx int, texture [1]gdclass.Texture2D)

Sets the icon of the item at index [param idx].

func (Instance) SetItemId

func (self Instance) SetItemId(idx int, id int)

Sets the ID of the item at index [param idx].

func (Instance) SetItemMetadata

func (self Instance) SetItemMetadata(idx int, metadata any)

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

func (self Instance) SetItemText(idx int, text string)

Sets the text of the item at index [param idx].

func (Instance) SetItemTooltip

func (self Instance) SetItemTooltip(idx int, tooltip string)

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].

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL