PopupMenu

package
v0.0.0-...-568b220 Latest Latest
Warning

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

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

Documentation

Overview

Package PopupMenu provides methods for working with PopupMenu 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
	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 [param event] against the [PopupMenu]'s shortcuts and accelerators, and activates the first item with matching events. If [param for_global_only] is [code]true[/code], only shortcuts and accelerators with [code]global[/code] set to [code]true[/code] will be called. Returns [code]true[/code] if an item was successfully activated. [b]Note:[/b] 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 [param label]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] for more info on accelerators. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param label] and icon [param texture]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] for more info on accelerators. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param texture] to it. Sets the label of the checkbox to the [Shortcut]'s name. An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param label] and icon [param texture]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] for more info on accelerators.

func (Expanded) AddIconRadioCheckItem

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

Same as [method add_icon_check_item], 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 [method add_icon_check_shortcut], 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 [param texture] to it. Sets the label of the checkbox to the [Shortcut]'s name. An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. If [param allow_echo] is [code]true[/code], 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 [param label]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] for more info on accelerators. [b]Note:[/b] The provided [param id] is used only in [signal id_pressed] and [signal id_focused] signals. It's not related to the [code]index[/code] arguments in e.g. [method set_item_checked].

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 [param label]. Contrarily to normal binary items, multistate items can have more than two states, as defined by [param max_states]. The default value is defined by [param default_state]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] 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] [b]Note:[/b] Multistate items don't update their state automatically and must be done manually. See [method toggle_item_multistate], [method set_item_multistate] and [method get_item_multistate] 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 [param label]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] for more info on accelerators. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param id] parameter. A [param 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 [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. If [param allow_echo] is [code]true[/code], 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 [param 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 [code]ui_select[/code] or [code]ui_right[/code] input actions. An [param id] can optionally be provided. If no [param 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 [code]ui_select[/code] or [code]ui_right[/code] input actions. [param 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 [param submenu] popup has another parent, this method will fail. An [param id] can optionally be provided. If no [param 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 [param free_submenus] is [code]true[/code], 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 [param 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

[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 [code]0[/code], the [PopupMenu] height will be limited by its parent rect. All [code]set_*[/code] methods allow negative item indices, i.e. [code]-1[/code] to access the last item, [code]-2[/code] to select the second-to-last item, and so on. [b]Incremental search:[/b] 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]. [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].

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 [param event] against the [PopupMenu]'s shortcuts and accelerators, and activates the first item with matching events. If [param for_global_only] is [code]true[/code], only shortcuts and accelerators with [code]global[/code] set to [code]true[/code] will be called. Returns [code]true[/code] if an item was successfully activated. [b]Note:[/b] 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 [param label]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] for more info on accelerators. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param label] and icon [param texture]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] for more info on accelerators. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param texture] to it. Sets the label of the checkbox to the [Shortcut]'s name. An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param label] and icon [param texture]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] for more info on accelerators.

func (Instance) AddIconRadioCheckItem

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

Same as [method add_icon_check_item], but uses a radio check button.

func (Instance) AddIconRadioCheckShortcut

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

Same as [method add_icon_check_shortcut], 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 [param texture] to it. Sets the label of the checkbox to the [Shortcut]'s name. An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. If [param allow_echo] is [code]true[/code], the shortcut can be activated with echo events.

func (Instance) AddItem

func (self Instance) AddItem(label string)

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

func (Instance) AddMultistateItem

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

Adds a new multistate item with text [param label]. Contrarily to normal binary items, multistate items can have more than two states, as defined by [param max_states]. The default value is defined by [param default_state]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] 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] [b]Note:[/b] Multistate items don't update their state automatically and must be done manually. See [method toggle_item_multistate], [method set_item_multistate] and [method get_item_multistate] 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 [param label]. An [param id] can optionally be provided, as well as an accelerator ([param accel]). If no [param id] is provided, one will be created from the index. If no [param accel] is provided, then the default value of 0 (corresponding to [constant @GlobalScope.KEY_NONE]) will be assigned to the item (which means it won't have any accelerator). See [method get_item_accelerator] for more info on accelerators. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] 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 [param id] parameter. A [param 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 [param id] can optionally be provided. If no [param id] is provided, one will be created from the index. If [param allow_echo] is [code]true[/code], 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 [param 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 [code]ui_select[/code] or [code]ui_right[/code] input actions. An [param id] can optionally be provided. If no [param 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 [code]ui_select[/code] or [code]ui_right[/code] input actions. [param 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 [param submenu] popup has another parent, this method will fail. An [param id] can optionally be provided. If no [param 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 [param free_submenus] is [code]true[/code], the submenu nodes are automatically freed.

func (Instance) GetFocusedItem

func (self Instance) GetFocusedItem() int

Returns the index of the currently focused item. Returns [code]-1[/code] 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 [param 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 [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]). If no accelerator is defined for the specified [param index], [method get_item_accelerator] returns [code]0[/code] (corresponding to [constant @GlobalScope.KEY_NONE]).

func (Instance) GetItemIcon

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

Returns the icon of the item at the given [param 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 [param index].

func (Instance) GetItemIconModulate

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

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

func (Instance) GetItemId

func (self Instance) GetItemId(index int) int

Returns the ID of the item at the given [param index]. [code]id[/code] 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 [param index].

func (Instance) GetItemIndex

func (self Instance) GetItemIndex(id int) int

Returns the index of the item containing the specified [param 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 [method set_item_metadata], 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 [param index].

func (Instance) GetItemMultistateMax

func (self Instance) GetItemMultistateMax(index int) int

Returns the max states of the item at the given [param index].

func (Instance) GetItemShortcut

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

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

func (Instance) GetItemSubmenu

func (self Instance) GetItemSubmenu(index int) string

Returns the submenu name of the item at the given [param index]. See [method add_submenu_item] 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 [param index], or [code]null[/code] if no submenu was added. See [method add_submenu_node_item] 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 [param 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 [param 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 [code]true[/code] if the item at the given [param index] is checkable in some way, i.e. if it has a checkbox or radio button. [b]Note:[/b] 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 [code]true[/code] if the item at the given [param index] is checked.

func (Instance) IsItemDisabled

func (self Instance) IsItemDisabled(index int) bool

Returns [code]true[/code] if the item at the given [param index] is disabled. When it is disabled it can't be selected, or its action invoked. See [method set_item_disabled] for more info on how to disable an item.

func (Instance) IsItemRadioCheckable

func (self Instance) IsItemRadioCheckable(index int) bool

Returns [code]true[/code] if the item at the given [param index] has radio button-style checkability. [b]Note:[/b] 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 [code]true[/code] if the item is a separator. If it is, it will be displayed as a line. See [method add_separator] for more info on how to add a separator.

func (Instance) IsItemShortcutDisabled

func (self Instance) IsItemShortcutDisabled(index int) bool

Returns [code]true[/code] if the specified item's shortcut is disabled.

func (Instance) IsNativeMenu

func (self Instance) IsNativeMenu() bool

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

func (Instance) IsSystemMenu

func (self Instance) IsSystemMenu() bool

Returns [code]true[/code] 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 [param index] from the menu. [b]Note:[/b] 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 [param 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 [param index]. Passing [code]-1[/code] 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 [param index]. An accelerator is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. [param accel] is generally a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]).

func (Instance) SetItemAsCheckable

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

Sets whether the item at the given [param index] has a checkbox. If [code]false[/code], sets the type of the item to plain text. [b]Note:[/b] 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 [param index] to radio button. If [code]false[/code], 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 [param index] as a separator, which means that it would be displayed as a line. If [code]false[/code], 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 [param 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 [param 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 [param 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 [param 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 [param index].

func (Instance) SetItemId

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

Sets the [param id] of the item at the given [param index]. The [param 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 [param 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 [method get_item_metadata], 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 [method add_multistate_item] for details.

func (Instance) SetItemMultistateMax

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

Sets the max states of a multistate item. See [method add_multistate_item] for details.

func (Instance) SetItemShortcut

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

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

func (Instance) SetItemShortcutDisabled

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

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

func (Instance) SetItemSubmenu

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

Sets the submenu of the item at the given [param 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 [param 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 [param 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 [param 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 [param 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 [param index].

func (Instance) ToggleItemMultistate

func (self Instance) ToggleItemMultistate(index int)

Cycle to the next state of a multistate item. See [method add_multistate_item] 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