PopupMenu

package
v0.0.0-...-ad02d68 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

[PopupMenu] is a modal window used to display a list of options. Useful for toolbars and context menus. The size of a [PopupMenu] can be limited by using [member Window.max_size]. If the height of the list of items is larger than the maximum height of the [PopupMenu], a [ScrollContainer] within the popup will allow the user to scroll the contents. If no maximum size is set, or if it is set to 0, the [PopupMenu] height will be limited by its parent rect. All set_* methods allow negative item indices, i.e. -1 to access the last item, -2 to select the second-to-last item, and so on. Incremental search: Like [ItemList] and [Tree], [PopupMenu] supports searching within the list while the control is focused. Press a key that matches the first letter of an item's name to select the first item starting with the given letter. After that point, there are two ways to perform incremental search: 1) Press the same key again before the timeout duration to select the next item starting with the same letter. 2) Press letter keys that match the rest of the word before the timeout duration to match to select the item in question directly. Both of these actions will be reset to the beginning of the list if the timeout duration has passed since the last keystroke was registered. You can adjust the timeout duration by changing [member ProjectSettings.gui/timers/incremental_search_max_interval_msec]. 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.

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
	AsPopupMenu() Instance
}

type Expanded

type Expanded [1]gdclass.PopupMenu

func (Expanded) ActivateItemByEvent

func (self Expanded) ActivateItemByEvent(event InputEvent.Instance, for_global_only bool) bool

Checks the provided 'event' against the [PopupMenu]'s shortcuts and accelerators, and activates the first item with matching events. If 'for_global_only' is true, only shortcuts and accelerators with global set to true will be called. Returns true if an item was successfully activated. Note: Certain [Control]s, such as [MenuButton], will call this method automatically.

func (Expanded) AddCheckItem

func (self Expanded) AddCheckItem(label string, id int, accel Input.Key)

Adds a new checkable item with text 'label'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Expanded) AddCheckShortcut

func (self Expanded) AddCheckShortcut(shortcut Shortcut.Instance, id int, global bool)

Adds a new checkable item and assigns the specified [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Expanded) AddIconCheckItem

func (self Expanded) AddIconCheckItem(texture Texture2D.Instance, label string, id int, accel Input.Key)

Adds a new checkable item with text 'label' and icon 'texture'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Expanded) AddIconCheckShortcut

func (self Expanded) AddIconCheckShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance, id int, global bool)

Adds a new checkable item and assigns the specified [Shortcut] and icon 'texture' to it. Sets the label of the checkbox to the [Shortcut]'s name. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Expanded) AddIconItem

func (self Expanded) AddIconItem(texture Texture2D.Instance, label string, id int, accel Input.Key)

Adds a new item with text 'label' and icon 'texture'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators.

func (Expanded) AddIconRadioCheckItem

func (self Expanded) AddIconRadioCheckItem(texture Texture2D.Instance, label string, id int, accel Input.Key)

Same as Instance.AddIconCheckItem, but uses a radio check button.

func (Expanded) AddIconRadioCheckShortcut

func (self Expanded) AddIconRadioCheckShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance, id int, global bool)

Same as Instance.AddIconCheckShortcut, but uses a radio check button.

func (Expanded) AddIconShortcut

func (self Expanded) AddIconShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance, id int, global bool, allow_echo bool)

Adds a new item and assigns the specified [Shortcut] and icon 'texture' to it. Sets the label of the checkbox to the [Shortcut]'s name. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. If 'allow_echo' is true, the shortcut can be activated with echo events.

func (Expanded) AddItem

func (self Expanded) AddItem(label string, id int, accel Input.Key)

Adds a new item with text 'label'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. Note: The provided 'id' is used only in [signal id_pressed] and [signal id_focused] signals. It's not related to the index arguments in e.g. Instance.SetItemChecked.

func (Expanded) AddMultistateItem

func (self Expanded) AddMultistateItem(label string, max_states int, default_state int, id int, accel Input.Key)

Adds a new multistate item with text 'label'. Contrarily to normal binary items, multistate items can have more than two states, as defined by 'max_states'. The default value is defined by 'default_state'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. [codeblock] func _ready():

add_multistate_item("Item", 3, 0)

index_pressed.connect(func(index: int):
        toggle_item_multistate(index)
        match get_item_multistate(index):
            0:
                print("First state")
            1:
                print("Second state")
            2:
                print("Third state")
    )

[/codeblock] Note: Multistate items don't update their state automatically and must be done manually. See Instance.ToggleItemMultistate, Instance.SetItemMultistate and Instance.GetItemMultistate for more info on how to control it.

func (Expanded) AddRadioCheckItem

func (self Expanded) AddRadioCheckItem(label string, id int, accel Input.Key)

Adds a new radio check button with text 'label'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Expanded) AddRadioCheckShortcut

func (self Expanded) AddRadioCheckShortcut(shortcut Shortcut.Instance, id int, global bool)

Adds a new radio check button and assigns a [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Expanded) AddSeparator

func (self Expanded) AddSeparator(label string, id int)

Adds a separator between items. Separators also occupy an index, which you can set by using the 'id' parameter. A 'label' can optionally be provided, which will appear at the center of the separator.

func (Expanded) AddShortcut

func (self Expanded) AddShortcut(shortcut Shortcut.Instance, id int, global bool, allow_echo bool)

Adds a [Shortcut]. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. If 'allow_echo' is true, the shortcut can be activated with echo events.

func (Expanded) AddSubmenuItem

func (self Expanded) AddSubmenuItem(label string, submenu string, id int)

Adds an item that will act as a submenu of the parent [PopupMenu] node when clicked. The 'submenu' argument must be the name of an existing [PopupMenu] that has been added as a child to this node. This submenu will be shown when the item is clicked, hovered for long enough, or activated using the ui_select or ui_right input actions. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index.

func (Expanded) AddSubmenuNodeItem

func (self Expanded) AddSubmenuNodeItem(label string, submenu Instance, id int)

Adds an item that will act as a submenu of the parent [PopupMenu] node when clicked. This submenu will be shown when the item is clicked, hovered for long enough, or activated using the ui_select or ui_right input actions. 'submenu' must be either child of this [PopupMenu] or has no parent node (in which case it will be automatically added as a child). If the 'submenu' popup has another parent, this method will fail. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index.

func (Expanded) Clear

func (self Expanded) Clear(free_submenus bool)

Removes all items from the [PopupMenu]. If 'free_submenus' is true, the submenu nodes are automatically freed.

func (Expanded) SetItemShortcut

func (self Expanded) SetItemShortcut(index int, shortcut Shortcut.Instance, global bool)

Sets a [Shortcut] for the item at the given 'index'.

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsPopup

func (self *Extension[T]) AsPopup() Popup.Instance

func (*Extension[T]) AsPopupMenu

func (self *Extension[T]) AsPopupMenu() Instance

func (*Extension[T]) AsViewport

func (self *Extension[T]) AsViewport() Viewport.Instance

func (*Extension[T]) AsWindow

func (self *Extension[T]) AsWindow() Window.Instance

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.PopupMenu

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 New

func New() Instance

func (Instance) ActivateItemByEvent

func (self Instance) ActivateItemByEvent(event InputEvent.Instance) bool

Checks the provided 'event' against the [PopupMenu]'s shortcuts and accelerators, and activates the first item with matching events. If 'for_global_only' is true, only shortcuts and accelerators with global set to true will be called. Returns true if an item was successfully activated. Note: Certain [Control]s, such as [MenuButton], will call this method automatically.

func (Instance) AddCheckItem

func (self Instance) AddCheckItem(label string)

Adds a new checkable item with text 'label'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Instance) AddCheckShortcut

func (self Instance) AddCheckShortcut(shortcut Shortcut.Instance)

Adds a new checkable item and assigns the specified [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Instance) AddIconCheckItem

func (self Instance) AddIconCheckItem(texture Texture2D.Instance, label string)

Adds a new checkable item with text 'label' and icon 'texture'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Instance) AddIconCheckShortcut

func (self Instance) AddIconCheckShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance)

Adds a new checkable item and assigns the specified [Shortcut] and icon 'texture' to it. Sets the label of the checkbox to the [Shortcut]'s name. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Instance) AddIconItem

func (self Instance) AddIconItem(texture Texture2D.Instance, label string)

Adds a new item with text 'label' and icon 'texture'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators.

func (Instance) AddIconRadioCheckItem

func (self Instance) AddIconRadioCheckItem(texture Texture2D.Instance, label string)

Same as Instance.AddIconCheckItem, but uses a radio check button.

func (Instance) AddIconRadioCheckShortcut

func (self Instance) AddIconRadioCheckShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance)

Same as Instance.AddIconCheckShortcut, but uses a radio check button.

func (Instance) AddIconShortcut

func (self Instance) AddIconShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance)

Adds a new item and assigns the specified [Shortcut] and icon 'texture' to it. Sets the label of the checkbox to the [Shortcut]'s name. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. If 'allow_echo' is true, the shortcut can be activated with echo events.

func (Instance) AddItem

func (self Instance) AddItem(label string)

Adds a new item with text 'label'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. Note: The provided 'id' is used only in [signal id_pressed] and [signal id_focused] signals. It's not related to the index arguments in e.g. Instance.SetItemChecked.

func (Instance) AddMultistateItem

func (self Instance) AddMultistateItem(label string, max_states int)

Adds a new multistate item with text 'label'. Contrarily to normal binary items, multistate items can have more than two states, as defined by 'max_states'. The default value is defined by 'default_state'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. [codeblock] func _ready():

add_multistate_item("Item", 3, 0)

index_pressed.connect(func(index: int):
        toggle_item_multistate(index)
        match get_item_multistate(index):
            0:
                print("First state")
            1:
                print("Second state")
            2:
                print("Third state")
    )

[/codeblock] Note: Multistate items don't update their state automatically and must be done manually. See Instance.ToggleItemMultistate, Instance.SetItemMultistate and Instance.GetItemMultistate for more info on how to control it.

func (Instance) AddRadioCheckItem

func (self Instance) AddRadioCheckItem(label string)

Adds a new radio check button with text 'label'. An 'id' can optionally be provided, as well as an accelerator ('accel'). If no 'id' is provided, one will be created from the index. If no 'accel' is provided, then the default value of 0 (corresponding to [@Globalscope.KeyNone]) will be assigned to the item (which means it won't have any accelerator). See Instance.GetItemAccelerator for more info on accelerators. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Instance) AddRadioCheckShortcut

func (self Instance) AddRadioCheckShortcut(shortcut Shortcut.Instance)

Adds a new radio check button and assigns a [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See Instance.SetItemChecked for more info on how to control it.

func (Instance) AddSeparator

func (self Instance) AddSeparator()

Adds a separator between items. Separators also occupy an index, which you can set by using the 'id' parameter. A 'label' can optionally be provided, which will appear at the center of the separator.

func (Instance) AddShortcut

func (self Instance) AddShortcut(shortcut Shortcut.Instance)

Adds a [Shortcut]. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index. If 'allow_echo' is true, the shortcut can be activated with echo events.

func (Instance) AddSubmenuItem

func (self Instance) AddSubmenuItem(label string, submenu string)

Adds an item that will act as a submenu of the parent [PopupMenu] node when clicked. The 'submenu' argument must be the name of an existing [PopupMenu] that has been added as a child to this node. This submenu will be shown when the item is clicked, hovered for long enough, or activated using the ui_select or ui_right input actions. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index.

func (Instance) AddSubmenuNodeItem

func (self Instance) AddSubmenuNodeItem(label string, submenu Instance)

Adds an item that will act as a submenu of the parent [PopupMenu] node when clicked. This submenu will be shown when the item is clicked, hovered for long enough, or activated using the ui_select or ui_right input actions. 'submenu' must be either child of this [PopupMenu] or has no parent node (in which case it will be automatically added as a child). If the 'submenu' popup has another parent, this method will fail. An 'id' can optionally be provided. If no 'id' is provided, one will be created from the index.

func (Instance) AllowSearch

func (self Instance) AllowSearch() bool

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

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

func (Instance) AsPopup

func (self Instance) AsPopup() Popup.Instance

func (Instance) AsPopupMenu

func (self Instance) AsPopupMenu() Instance

func (Instance) AsViewport

func (self Instance) AsViewport() Viewport.Instance

func (Instance) AsWindow

func (self Instance) AsWindow() Window.Instance

func (Instance) Clear

func (self Instance) Clear()

Removes all items from the [PopupMenu]. If 'free_submenus' is true, the submenu nodes are automatically freed.

func (Instance) GetFocusedItem

func (self Instance) GetFocusedItem() int

Returns the index of the currently focused item. Returns -1 if no item is focused.

func (Instance) GetItemAccelerator

func (self Instance) GetItemAccelerator(index int) Input.Key

Returns the accelerator of the item at the given 'index'. An accelerator is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The return value is an integer which is generally a combination of [KeyModifierMask]s and [Key]s using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]). If no accelerator is defined for the specified 'index', Instance.GetItemAccelerator returns 0 (corresponding to [@Globalscope.KeyNone]).

func (Instance) GetItemIcon

func (self Instance) GetItemIcon(index int) Texture2D.Instance

Returns the icon of the item at the given 'index'.

func (Instance) GetItemIconMaxWidth

func (self Instance) GetItemIconMaxWidth(index int) int

Returns the maximum allowed width of the icon for the item at the given 'index'.

func (Instance) GetItemIconModulate

func (self Instance) GetItemIconModulate(index int) Color.RGBA

Returns a [Color] modulating the item's icon at the given 'index'.

func (Instance) GetItemId

func (self Instance) GetItemId(index int) int

Returns the ID of the item at the given 'index'. id can be manually assigned, while index can not.

func (Instance) GetItemIndent

func (self Instance) GetItemIndent(index int) int

Returns the horizontal offset of the item at the given 'index'.

func (Instance) GetItemIndex

func (self Instance) GetItemIndex(id int) int

Returns the index of the item containing the specified 'id'. Index is automatically assigned to each item by the engine and can not be set manually.

func (Instance) GetItemLanguage

func (self Instance) GetItemLanguage(index int) string

Returns item's text language code.

func (Instance) GetItemMetadata

func (self Instance) GetItemMetadata(index int) any

Returns the metadata of the specified item, which might be of any type. You can set it with Instance.SetItemMetadata, which provides a simple way of assigning context data to items.

func (Instance) GetItemMultistate

func (self Instance) GetItemMultistate(index int) int

Returns the state of the item at the given 'index'.

func (Instance) GetItemMultistateMax

func (self Instance) GetItemMultistateMax(index int) int

Returns the max states of the item at the given 'index'.

func (Instance) GetItemShortcut

func (self Instance) GetItemShortcut(index int) Shortcut.Instance

Returns the [Shortcut] associated with the item at the given 'index'.

func (Instance) GetItemSubmenu

func (self Instance) GetItemSubmenu(index int) string

Returns the submenu name of the item at the given 'index'. See Instance.AddSubmenuItem for more info on how to add a submenu.

func (Instance) GetItemSubmenuNode

func (self Instance) GetItemSubmenuNode(index int) Instance

Returns the submenu of the item at the given 'index', or null if no submenu was added. See Instance.AddSubmenuNodeItem for more info on how to add a submenu.

func (Instance) GetItemText

func (self Instance) GetItemText(index int) string

Returns the text of the item at the given 'index'.

func (Instance) GetItemTextDirection

func (self Instance) GetItemTextDirection(index int) Control.TextDirection

Returns item's text base writing direction.

func (Instance) GetItemTooltip

func (self Instance) GetItemTooltip(index int) string

Returns the tooltip associated with the item at the given 'index'.

func (Instance) HideOnCheckableItemSelection

func (self Instance) HideOnCheckableItemSelection() bool

func (Instance) HideOnItemSelection

func (self Instance) HideOnItemSelection() bool

func (Instance) HideOnStateItemSelection

func (self Instance) HideOnStateItemSelection() bool

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsItemCheckable

func (self Instance) IsItemCheckable(index int) bool

Returns true if the item at the given 'index' is checkable in some way, i.e. if it has a checkbox or radio button. Note: Checkable items just display a checkmark or radio button, but don't have any built-in checking behavior and must be checked/unchecked manually.

func (Instance) IsItemChecked

func (self Instance) IsItemChecked(index int) bool

Returns true if the item at the given 'index' is checked.

func (Instance) IsItemDisabled

func (self Instance) IsItemDisabled(index int) bool

Returns true if the item at the given 'index' is disabled. When it is disabled it can't be selected, or its action invoked. See Instance.SetItemDisabled for more info on how to disable an item.

func (Instance) IsItemRadioCheckable

func (self Instance) IsItemRadioCheckable(index int) bool

Returns true if the item at the given 'index' has radio button-style checkability. Note: This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.

func (Instance) IsItemSeparator

func (self Instance) IsItemSeparator(index int) bool

Returns true if the item is a separator. If it is, it will be displayed as a line. See Instance.AddSeparator for more info on how to add a separator.

func (Instance) IsItemShortcutDisabled

func (self Instance) IsItemShortcutDisabled(index int) bool

Returns true if the specified item's shortcut is disabled.

func (Instance) IsNativeMenu

func (self Instance) IsNativeMenu() bool

Returns true if the system native menu is supported and currently used by this [PopupMenu].

func (Instance) IsSystemMenu

func (self Instance) IsSystemMenu() bool

Returns true if the menu is bound to the special system menu.

func (Instance) ItemCount

func (self Instance) ItemCount() int

func (Instance) OnIdFocused

func (self Instance) OnIdFocused(cb func(id int), flags ...Signal.Flags)

func (Instance) OnIdPressed

func (self Instance) OnIdPressed(cb func(id int), flags ...Signal.Flags)

func (Instance) OnIndexPressed

func (self Instance) OnIndexPressed(cb func(index int), flags ...Signal.Flags)

func (Instance) OnMenuChanged

func (self Instance) OnMenuChanged(cb func(), flags ...Signal.Flags)

func (Instance) PreferNativeMenu

func (self Instance) PreferNativeMenu() bool

func (Instance) RemoveItem

func (self Instance) RemoveItem(index int)

Removes the item at the given 'index' from the menu. Note: The indices of items after the removed item will be shifted by one.

func (Instance) ScrollToItem

func (self Instance) ScrollToItem(index int)

Moves the scroll view to make the item at the given 'index' visible.

func (Instance) SetAllowSearch

func (self Instance) SetAllowSearch(value bool)

func (Instance) SetFocusedItem

func (self Instance) SetFocusedItem(index int)

Sets the currently focused item as the given 'index'. Passing -1 as the index makes so that no item is focused.

func (Instance) SetHideOnCheckableItemSelection

func (self Instance) SetHideOnCheckableItemSelection(value bool)

func (Instance) SetHideOnItemSelection

func (self Instance) SetHideOnItemSelection(value bool)

func (Instance) SetHideOnStateItemSelection

func (self Instance) SetHideOnStateItemSelection(value bool)

func (Instance) SetItemAccelerator

func (self Instance) SetItemAccelerator(index int, accel Input.Key)

Sets the accelerator of the item at the given 'index'. An accelerator is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. 'accel' is generally a combination of [KeyModifierMask]s and [Key]s using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]).

func (Instance) SetItemAsCheckable

func (self Instance) SetItemAsCheckable(index int, enable bool)

Sets whether the item at the given 'index' has a checkbox. If false, sets the type of the item to plain text. Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.

func (Instance) SetItemAsRadioCheckable

func (self Instance) SetItemAsRadioCheckable(index int, enable bool)

Sets the type of the item at the given 'index' to radio button. If false, sets the type of the item to plain text.

func (Instance) SetItemAsSeparator

func (self Instance) SetItemAsSeparator(index int, enable bool)

Mark the item at the given 'index' as a separator, which means that it would be displayed as a line. If false, sets the type of the item to plain text.

func (Instance) SetItemChecked

func (self Instance) SetItemChecked(index int, checked bool)

Sets the checkstate status of the item at the given 'index'.

func (Instance) SetItemCount

func (self Instance) SetItemCount(value int)

func (Instance) SetItemDisabled

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

Enables/disables the item at the given 'index'. When it is disabled, it can't be selected and its action can't be invoked.

func (Instance) SetItemIcon

func (self Instance) SetItemIcon(index int, icon Texture2D.Instance)

Replaces the [Texture2D] icon of the item at the given 'index'.

func (Instance) SetItemIconMaxWidth

func (self Instance) SetItemIconMaxWidth(index int, width int)

Sets the maximum allowed width of the icon for the item at the given 'index'. This limit is applied on top of the default size of the icon and on top of [theme_item icon_max_width]. The height is adjusted according to the icon's ratio.

func (Instance) SetItemIconModulate

func (self Instance) SetItemIconModulate(index int, modulate Color.RGBA)

Sets a modulating [Color] of the item's icon at the given 'index'.

func (Instance) SetItemId

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

Sets the 'id' of the item at the given 'index'. The 'id' is used in [signal id_pressed] and [signal id_focused] signals.

func (Instance) SetItemIndent

func (self Instance) SetItemIndent(index int, indent int)

Sets the horizontal offset of the item at the given 'index'.

func (Instance) SetItemLanguage

func (self Instance) SetItemLanguage(index int, language string)

Sets language code of item's text used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

func (Instance) SetItemMetadata

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

Sets the metadata of an item, which may be of any type. You can later get it with Instance.GetItemMetadata, which provides a simple way of assigning context data to items.

func (Instance) SetItemMultistate

func (self Instance) SetItemMultistate(index int, state int)

Sets the state of a multistate item. See Instance.AddMultistateItem for details.

func (Instance) SetItemMultistateMax

func (self Instance) SetItemMultistateMax(index int, max_states int)

Sets the max states of a multistate item. See Instance.AddMultistateItem for details.

func (Instance) SetItemShortcut

func (self Instance) SetItemShortcut(index int, shortcut Shortcut.Instance)

Sets a [Shortcut] for the item at the given 'index'.

func (Instance) SetItemShortcutDisabled

func (self Instance) SetItemShortcutDisabled(index int, disabled bool)

Disables the [Shortcut] of the item at the given 'index'.

func (Instance) SetItemSubmenu

func (self Instance) SetItemSubmenu(index int, submenu string)

Sets the submenu of the item at the given 'index'. The submenu is the name of a child [PopupMenu] node that would be shown when the item is clicked.

func (Instance) SetItemSubmenuNode

func (self Instance) SetItemSubmenuNode(index int, submenu Instance)

Sets the submenu of the item at the given 'index'. The submenu is a [PopupMenu] node that would be shown when the item is clicked. It must either be a child of this [PopupMenu] or has no parent (in which case it will be automatically added as a child). If the 'submenu' popup has another parent, this method will fail.

func (Instance) SetItemText

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

Sets the text of the item at the given 'index'.

func (Instance) SetItemTextDirection

func (self Instance) SetItemTextDirection(index int, direction Control.TextDirection)

Sets item's text base writing direction.

func (Instance) SetItemTooltip

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

Sets the [String] tooltip of the item at the given 'index'.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetPreferNativeMenu

func (self Instance) SetPreferNativeMenu(value bool)

func (Instance) SetSubmenuPopupDelay

func (self Instance) SetSubmenuPopupDelay(value Float.X)

func (Instance) SetSystemMenuId

func (self Instance) SetSystemMenuId(value NativeMenu.SystemMenus)

func (Instance) SubmenuPopupDelay

func (self Instance) SubmenuPopupDelay() Float.X

func (Instance) SystemMenuId

func (self Instance) SystemMenuId() NativeMenu.SystemMenus

func (Instance) ToggleItemChecked

func (self Instance) ToggleItemChecked(index int)

Toggles the check state of the item at the given 'index'.

func (Instance) ToggleItemMultistate

func (self Instance) ToggleItemMultistate(index int)

Cycle to the next state of a multistate item. See Instance.AddMultistateItem for details.

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