Signal2
Signal support.
PopupMenu.swift:2916class Signal2
Use the connect(flags:_:)
method to connect to the signal on the container object, and disconnect(_:)
to drop the connection.
You can also await the emitted
property for waiting for a single emission of the signal.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (76) members.
Types
class Signal1
Signal support.
class Signal3
Signal support.
Type members
Instance members
var allowSearch: Bool
If
true
, allows navigatingPopupMenu
with letter keys.var hideOnCheckableItemSelection: Bool
If
true
, hides thePopupMenu
when a checkbox or radio button is selected.var hideOnItemSelection: Bool
If
true
, hides thePopupMenu
when an item is selected.var hideOnStateItemSelection: Bool
If
true
, hides thePopupMenu
when a state item is selected.var idFocused: Signal2
Emitted when the user navigated to an item of some
id
using theProjectSettings/input/uiUp
orProjectSettings/input/uiDown
input action.var idPressed: Signal1
Emitted when an item of some
id
is pressed or its accelerator is activated.var indexPressed: Signal3
Emitted when an item of some
index
is pressed or its accelerator is activated.var itemCount: Int32
The number of items currently in the list.
func activateItemByEvent(InputEvent?, forGlobalOnly: Bool
) -> Bool Checks the provided
event
against thePopupMenu
’s shortcuts and accelerators, and activates the first item with matching events. IfforGlobalOnly
istrue
, only shortcuts and accelerators withglobal
set totrue
will be called.func addCheckItem(label: String, id: Int32, accel: Key
) Adds a new checkable item with text
label
.func addCheckShortcut(Shortcut?, id: Int32, global: Bool
) Adds a new checkable item and assigns the specified
Shortcut
to it. Sets the label of the checkbox to theShortcut
’s name.func addIconCheckItem(texture: Texture2D?, label: String, id: Int32, accel: Key
) Adds a new checkable item with text
label
and icontexture
.func addIconCheckShortcut(texture: Texture2D?, shortcut: Shortcut?, id: Int32, global: Bool
) Adds a new checkable item and assigns the specified
Shortcut
and icontexture
to it. Sets the label of the checkbox to theShortcut
’s name.func addIconItem(texture: Texture2D?, label: String, id: Int32, accel: Key
) Adds a new item with text
label
and icontexture
.func addIconRadioCheckItem(texture: Texture2D?, label: String, id: Int32, accel: Key
) Same as
addIconCheckItem(texture:label:id:accel:)
, but uses a radio check button.func addIconRadioCheckShortcut(texture: Texture2D?, shortcut: Shortcut?, id: Int32, global: Bool
) Same as
addIconCheckShortcut(texture:shortcut:id:global:)
, but uses a radio check button.func addIconShortcut(texture: Texture2D?, shortcut: Shortcut?, id: Int32, global: Bool, allowEcho: Bool
) Adds a new item and assigns the specified
Shortcut
and icontexture
to it. Sets the label of the checkbox to theShortcut
’s name.func addItem(label: String, id: Int32, accel: Key
) Adds a new item with text
label
.func addMultistateItem(label: String, maxStates: Int32, defaultState: Int32, id: Int32, accel: Key
) Adds a new multistate item with text
label
.func addRadioCheckItem(label: String, id: Int32, accel: Key
) Adds a new radio check button with text
label
.func addRadioCheckShortcut(Shortcut?, id: Int32, global: Bool
) Adds a new radio check button and assigns a
Shortcut
to it. Sets the label of the checkbox to theShortcut
’s name.func addSeparator(label: String, id: Int32
) Adds a separator between items. Separators also occupy an index, which you can set by using the
id
parameter.func addShortcut(Shortcut?, id: Int32, global: Bool, allowEcho: Bool
) Adds a
Shortcut
.func getFocusedItem(
) -> Int32 Returns the index of the currently focused item. Returns
-1
if no item is focused.func getItemAccelerator(index: Int32
) -> 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 ofKeyModifierMask
s andKey
s using bitwise OR such asKEY_MASK_CTRL | KEY_A
([kbd]Ctrl + A[/kbd]). If no accelerator is defined for the specifiedindex
,getItemAccelerator(index:)
returns0
(corresponding to@GlobalScope.KEY_NONE
).func getItemIcon(index: Int32
) -> Texture2D? Returns the icon of the item at the given
index
.func getItemIconMaxWidth(index: Int32
) -> Int32 Returns the maximum allowed width of the icon for the item at the given
index
.func getItemIconModulate(index: Int32
) -> Color Returns a
Color
modulating the item’s icon at the givenindex
.func getItemId(index: Int32
) -> Int32 Returns the ID of the item at the given
index
.id
can be manually assigned, while index can not.func getItemIndent(index: Int32
) -> Int32 Returns the horizontal offset of the item at the given
index
.func getItemIndex(id: Int32
) -> Int32 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 getItemLanguage(index: Int32
) -> String Returns item’s text language code.
func getItemMetadata(index: Int32
) -> Variant Returns the metadata of the specified item, which might be of any type. You can set it with
setItemMetadata(index:metadata:)
, which provides a simple way of assigning context data to items.func getItemShortcut(index: Int32
) -> Shortcut? Returns the
Shortcut
associated with the item at the givenindex
.func getItemText(index: Int32
) -> String Returns the text of the item at the given
index
.func getItemTextDirection(index: Int32
) -> Control.TextDirection Returns item’s text base writing direction.
func getItemTooltip(index: Int32
) -> String Returns the tooltip associated with the item at the given
index
.func isItemCheckable(index: Int32
) -> Bool Returns
true
if the item at the givenindex
is checkable in some way, i.e. if it has a checkbox or radio button.func isItemChecked(index: Int32
) -> Bool Returns
true
if the item at the givenindex
is checked.func isItemDisabled(index: Int32
) -> Bool Returns
true
if the item at the givenindex
is disabled. When it is disabled it can’t be selected, or its action invoked.func isItemRadioCheckable(index: Int32
) -> Bool Returns
true
if the item at the givenindex
has radio button-style checkability.func isItemSeparator(index: Int32
) -> Bool Returns
true
if the item is a separator. If it is, it will be displayed as a line. SeeaddSeparator(label:id:)
for more info on how to add a separator.func isItemShortcutDisabled(index: Int32
) -> Bool Returns
true
if the specified item’s shortcut is disabled.func removeItem(index: Int32
) Removes the item at the given
index
from the menu.func scrollToItem(index: Int32
) Moves the scroll view to make the item at the given
index
visible.func setFocusedItem(index: Int32
) Sets the currently focused item as the given
index
.func setItemAccelerator(index: Int32, accel: 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 ofKeyModifierMask
s andKey
s using bitwise OR such asKEY_MASK_CTRL | KEY_A
([kbd]Ctrl + A[/kbd]).func setItemAsCheckable(index: Int32, enable: Bool
) Sets whether the item at the given
index
has a checkbox. Iffalse
, sets the type of the item to plain text.func setItemAsRadioCheckable(index: Int32, enable: Bool
) Sets the type of the item at the given
index
to radio button. Iffalse
, sets the type of the item to plain text.func setItemAsSeparator(index: Int32, enable: Bool
) Mark the item at the given
index
as a separator, which means that it would be displayed as a line. Iffalse
, sets the type of the item to plain text.func setItemChecked(index: Int32, checked: Bool
) Sets the checkstate status of the item at the given
index
.func setItemDisabled(index: Int32, 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 setItemIcon(index: Int32, icon: Texture2D?
) Replaces the
Texture2D
icon of the item at the givenindex
.func setItemIconMaxWidth(index: Int32, width: Int32
) 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 setItemIconModulate(index: Int32, modulate: Color
) Sets a modulating
Color
of the item’s icon at the givenindex
.func setItemId(index: Int32, id: Int32
) Sets the
id
of the item at the givenindex
.func setItemIndent(index: Int32, indent: Int32
) Sets the horizontal offset of the item at the given
index
.func setItemLanguage(index: Int32, 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 setItemMetadata(index: Int32, metadata: Variant
) Sets the metadata of an item, which may be of any type. You can later get it with
getItemMetadata(index:)
, which provides a simple way of assigning context data to items.func setItemMultistate(index: Int32, state: Int32
) Sets the state of a multistate item. See
addMultistateItem(label:maxStates:defaultState:id:accel:)
for details.func setItemShortcut(index: Int32, shortcut: Shortcut?, global: Bool
) Sets a
Shortcut
for the item at the givenindex
.func setItemShortcutDisabled(index: Int32, disabled: Bool
) Disables the
Shortcut
of the item at the givenindex
.func setItemText(index: Int32, text: String
) Sets the text of the item at the given
index
.func setItemTextDirection(index: Int32, direction: Control.TextDirection
) Sets item’s text base writing direction.
func setItemTooltip(index: Int32, tooltip: String
) Sets the
String
tooltip of the item at the givenindex
.func toggleItemChecked(index: Int32
) Toggles the check state of the item at the given
index
.func toggleItemMultistate(index: Int32
) Cycle to the next state of a multistate item. See
addMultistateItem(label:maxStates:defaultState:id:accel:)
for details.
Citizens in SwiftGodot
Instance members
var emitted: Void
You can await this property to wait for the signal to be emitted once
func connect(flags: Object.ConnectFlags, @escaping (_ id: Int64) -> ()
) -> Object Connects the signal to the specified callback
func disconnect(Object
) Disconnects a signal that was previously connected, the return value from calling
connect(flags:_:)