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 ¶
- type Advanced
- type Any
- type Expanded
- func (self Expanded) ActivateItemByEvent(event InputEvent.Instance, for_global_only bool) bool
- func (self Expanded) AddCheckItem(label string, id int, accel Input.Key)
- func (self Expanded) AddCheckShortcut(shortcut Shortcut.Instance, id int, global bool)
- func (self Expanded) AddIconCheckItem(texture Texture2D.Instance, label string, id int, accel Input.Key)
- func (self Expanded) AddIconCheckShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance, id int, global bool)
- func (self Expanded) AddIconItem(texture Texture2D.Instance, label string, id int, accel Input.Key)
- func (self Expanded) AddIconRadioCheckItem(texture Texture2D.Instance, label string, id int, accel Input.Key)
- func (self Expanded) AddIconRadioCheckShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance, id int, global bool)
- func (self Expanded) AddIconShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance, id int, global bool, ...)
- func (self Expanded) AddItem(label string, id int, accel Input.Key)
- func (self Expanded) AddMultistateItem(label string, max_states int, default_state int, id int, accel Input.Key)
- func (self Expanded) AddRadioCheckItem(label string, id int, accel Input.Key)
- func (self Expanded) AddRadioCheckShortcut(shortcut Shortcut.Instance, id int, global bool)
- func (self Expanded) AddSeparator(label string, id int)
- func (self Expanded) AddShortcut(shortcut Shortcut.Instance, id int, global bool, allow_echo bool)
- func (self Expanded) AddSubmenuItem(label string, submenu string, id int)
- func (self Expanded) AddSubmenuNodeItem(label string, submenu Instance, id int)
- func (self Expanded) Clear(free_submenus bool)
- func (self Expanded) SetItemShortcut(index int, shortcut Shortcut.Instance, global bool)
- type Extension
- func (self *Extension[T]) AsNode() Node.Instance
- func (self *Extension[T]) AsObject() [1]gd.Object
- func (self *Extension[T]) AsPopup() Popup.Instance
- func (self *Extension[T]) AsPopupMenu() Instance
- func (self *Extension[T]) AsViewport() Viewport.Instance
- func (self *Extension[T]) AsWindow() Window.Instance
- type ID
- type Instance
- func (self Instance) ActivateItemByEvent(event InputEvent.Instance) bool
- func (self Instance) AddCheckItem(label string)
- func (self Instance) AddCheckShortcut(shortcut Shortcut.Instance)
- func (self Instance) AddIconCheckItem(texture Texture2D.Instance, label string)
- func (self Instance) AddIconCheckShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance)
- func (self Instance) AddIconItem(texture Texture2D.Instance, label string)
- func (self Instance) AddIconRadioCheckItem(texture Texture2D.Instance, label string)
- func (self Instance) AddIconRadioCheckShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance)
- func (self Instance) AddIconShortcut(texture Texture2D.Instance, shortcut Shortcut.Instance)
- func (self Instance) AddItem(label string)
- func (self Instance) AddMultistateItem(label string, max_states int)
- func (self Instance) AddRadioCheckItem(label string)
- func (self Instance) AddRadioCheckShortcut(shortcut Shortcut.Instance)
- func (self Instance) AddSeparator()
- func (self Instance) AddShortcut(shortcut Shortcut.Instance)
- func (self Instance) AddSubmenuItem(label string, submenu string)
- func (self Instance) AddSubmenuNodeItem(label string, submenu Instance)
- func (self Instance) AllowSearch() bool
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsPopup() Popup.Instance
- func (self Instance) AsPopupMenu() Instance
- func (self Instance) AsViewport() Viewport.Instance
- func (self Instance) AsWindow() Window.Instance
- func (self Instance) Clear()
- func (self Instance) GetFocusedItem() int
- func (self Instance) GetItemAccelerator(index int) Input.Key
- func (self Instance) GetItemIcon(index int) Texture2D.Instance
- func (self Instance) GetItemIconMaxWidth(index int) int
- func (self Instance) GetItemIconModulate(index int) Color.RGBA
- func (self Instance) GetItemId(index int) int
- func (self Instance) GetItemIndent(index int) int
- func (self Instance) GetItemIndex(id int) int
- func (self Instance) GetItemLanguage(index int) string
- func (self Instance) GetItemMetadata(index int) any
- func (self Instance) GetItemMultistate(index int) int
- func (self Instance) GetItemMultistateMax(index int) int
- func (self Instance) GetItemShortcut(index int) Shortcut.Instance
- func (self Instance) GetItemSubmenu(index int) string
- func (self Instance) GetItemSubmenuNode(index int) Instance
- func (self Instance) GetItemText(index int) string
- func (self Instance) GetItemTextDirection(index int) Control.TextDirection
- func (self Instance) GetItemTooltip(index int) string
- func (self Instance) HideOnCheckableItemSelection() bool
- func (self Instance) HideOnItemSelection() bool
- func (self Instance) HideOnStateItemSelection() bool
- func (self Instance) ID() ID
- func (self Instance) IsItemCheckable(index int) bool
- func (self Instance) IsItemChecked(index int) bool
- func (self Instance) IsItemDisabled(index int) bool
- func (self Instance) IsItemRadioCheckable(index int) bool
- func (self Instance) IsItemSeparator(index int) bool
- func (self Instance) IsItemShortcutDisabled(index int) bool
- func (self Instance) IsNativeMenu() bool
- func (self Instance) IsSystemMenu() bool
- func (self Instance) ItemCount() int
- func (self Instance) OnIdFocused(cb func(id int), flags ...Signal.Flags)
- func (self Instance) OnIdPressed(cb func(id int), flags ...Signal.Flags)
- func (self Instance) OnIndexPressed(cb func(index int), flags ...Signal.Flags)
- func (self Instance) OnMenuChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) PreferNativeMenu() bool
- func (self Instance) RemoveItem(index int)
- func (self Instance) ScrollToItem(index int)
- func (self Instance) SetAllowSearch(value bool)
- func (self Instance) SetFocusedItem(index int)
- func (self Instance) SetHideOnCheckableItemSelection(value bool)
- func (self Instance) SetHideOnItemSelection(value bool)
- func (self Instance) SetHideOnStateItemSelection(value bool)
- func (self Instance) SetItemAccelerator(index int, accel Input.Key)
- func (self Instance) SetItemAsCheckable(index int, enable bool)
- func (self Instance) SetItemAsRadioCheckable(index int, enable bool)
- func (self Instance) SetItemAsSeparator(index int, enable bool)
- func (self Instance) SetItemChecked(index int, checked bool)
- func (self Instance) SetItemCount(value int)
- func (self Instance) SetItemDisabled(index int, disabled bool)
- func (self Instance) SetItemIcon(index int, icon Texture2D.Instance)
- func (self Instance) SetItemIconMaxWidth(index int, width int)
- func (self Instance) SetItemIconModulate(index int, modulate Color.RGBA)
- func (self Instance) SetItemId(index int, id int)
- func (self Instance) SetItemIndent(index int, indent int)
- func (self Instance) SetItemLanguage(index int, language string)
- func (self Instance) SetItemMetadata(index int, metadata any)
- func (self Instance) SetItemMultistate(index int, state int)
- func (self Instance) SetItemMultistateMax(index int, max_states int)
- func (self Instance) SetItemShortcut(index int, shortcut Shortcut.Instance)
- func (self Instance) SetItemShortcutDisabled(index int, disabled bool)
- func (self Instance) SetItemSubmenu(index int, submenu string)
- func (self Instance) SetItemSubmenuNode(index int, submenu Instance)
- func (self Instance) SetItemText(index int, text string)
- func (self Instance) SetItemTextDirection(index int, direction Control.TextDirection)
- func (self Instance) SetItemTooltip(index int, tooltip string)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPreferNativeMenu(value bool)
- func (self Instance) SetSubmenuPopupDelay(value Float.X)
- func (self Instance) SetSystemMenuId(value NativeMenu.SystemMenus)
- func (self Instance) SubmenuPopupDelay() Float.X
- func (self Instance) SystemMenuId() NativeMenu.SystemMenus
- func (self Instance) ToggleItemChecked(index int)
- func (self Instance) ToggleItemMultistate(index int)
- 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 Expanded ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
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]) AsPopupMenu ¶
func (*Extension[T]) AsViewport ¶
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 ¶
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) 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 (Instance) AsPopupMenu ¶
func (Instance) AsViewport ¶
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 ¶
Returns the index of the currently focused item. Returns -1 if no item is focused.
func (Instance) GetItemAccelerator ¶
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 ¶
Returns the icon of the item at the given 'index'.
func (Instance) GetItemIconMaxWidth ¶
Returns the maximum allowed width of the icon for the item at the given 'index'.
func (Instance) GetItemIconModulate ¶
Returns a [Color] modulating the item's icon at the given 'index'.
func (Instance) GetItemId ¶
Returns the ID of the item at the given 'index'. id can be manually assigned, while index can not.
func (Instance) GetItemIndent ¶
Returns the horizontal offset of the item at the given 'index'.
func (Instance) GetItemIndex ¶
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 ¶
Returns item's text language code.
func (Instance) GetItemMetadata ¶
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 ¶
Returns the state of the item at the given 'index'.
func (Instance) GetItemMultistateMax ¶
Returns the max states of the item at the given 'index'.
func (Instance) GetItemShortcut ¶
Returns the [Shortcut] associated with the item at the given 'index'.
func (Instance) GetItemSubmenu ¶
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 ¶
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 ¶
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 ¶
Returns the tooltip associated with the item at the given 'index'.
func (Instance) HideOnCheckableItemSelection ¶
func (Instance) HideOnItemSelection ¶
func (Instance) HideOnStateItemSelection ¶
func (Instance) IsItemCheckable ¶
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 ¶
Returns true if the item at the given 'index' is checked.
func (Instance) IsItemDisabled ¶
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 ¶
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 ¶
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 ¶
Returns true if the specified item's shortcut is disabled.
func (Instance) IsNativeMenu ¶
Returns true if the system native menu is supported and currently used by this [PopupMenu].
func (Instance) IsSystemMenu ¶
Returns true if the menu is bound to the special system menu.
func (Instance) OnIdFocused ¶
func (Instance) OnIdPressed ¶
func (Instance) OnIndexPressed ¶
func (Instance) OnMenuChanged ¶
func (Instance) PreferNativeMenu ¶
func (Instance) RemoveItem ¶
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 ¶
Moves the scroll view to make the item at the given 'index' visible.
func (Instance) SetAllowSearch ¶
func (Instance) SetFocusedItem ¶
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 (Instance) SetHideOnItemSelection ¶
func (Instance) SetHideOnStateItemSelection ¶
func (Instance) SetItemAccelerator ¶
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 ¶
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 ¶
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 ¶
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 ¶
Sets the checkstate status of the item at the given 'index'.
func (Instance) SetItemCount ¶
func (Instance) SetItemDisabled ¶
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 ¶
Replaces the [Texture2D] icon of the item at the given 'index'.
func (Instance) SetItemIconMaxWidth ¶
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 ¶
Sets a modulating [Color] of the item's icon at the given 'index'.
func (Instance) SetItemId ¶
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 ¶
Sets the horizontal offset of the item at the given 'index'.
func (Instance) SetItemLanguage ¶
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 ¶
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 ¶
Sets the state of a multistate item. See Instance.AddMultistateItem for details.
func (Instance) SetItemMultistateMax ¶
Sets the max states of a multistate item. See Instance.AddMultistateItem for details.
func (Instance) SetItemShortcut ¶
Sets a [Shortcut] for the item at the given 'index'.
func (Instance) SetItemShortcutDisabled ¶
Disables the [Shortcut] of the item at the given 'index'.
func (Instance) SetItemSubmenu ¶
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 ¶
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 ¶
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 ¶
Sets the [String] tooltip of the item at the given 'index'.
func (Instance) SetPreferNativeMenu ¶
func (Instance) SetSubmenuPopupDelay ¶
func (Instance) SetSystemMenuId ¶
func (self Instance) SetSystemMenuId(value NativeMenu.SystemMenus)
func (Instance) SubmenuPopupDelay ¶
func (Instance) SystemMenuId ¶
func (self Instance) SystemMenuId() NativeMenu.SystemMenus
func (Instance) ToggleItemChecked ¶
Toggles the check state of the item at the given 'index'.
func (Instance) ToggleItemMultistate ¶
Cycle to the next state of a multistate item. See Instance.AddMultistateItem for details.