Signal2
Signal support.
OptionButton.swift:1176class 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 (35) members.
Types
class Signal1
Signal support.
Type members
Instance members
var allowReselect: Bool
If
true
, the currently selected item can be selected again.var fitToLongestItem: Bool
If
true
, minimum size will be determined by the longest item’s text, instead of the currently selected one’s.var itemCount: Int32
The number of items to select from.
var itemFocused: Signal2
Emitted when the user navigates to an item using the
ProjectSettings/input/uiUp
orProjectSettings/input/uiDown
input actions. The index of the item selected is passed as argument.var itemSelected: Signal1
Emitted when the current item has been changed by the user. The index of the item selected is passed as argument.
func addIconItem(texture: Texture2D?, label: String, id: Int32
) Adds an item, with a
texture
icon, textlabel
and (optionally)id
. If noid
is passed, the item index will be used as the item’s ID. New items are appended at the end.func addItem(label: String, id: Int32
) Adds an item, with text
label
and (optionally)id
. If noid
is passed, the item index will be used as the item’s ID. New items are appended at the end.func addSeparator(text: String
) Adds a separator to the list of items. Separators help to group items, and can optionally be given a
text
header. A separator also gets an index assigned, and is appended at the end of the item list.func clear(
) Clears all the items in the
OptionButton
.func getItemIcon(idx: Int32
) -> Texture2D? Returns the icon of the item at index
idx
.func getItemId(idx: Int32
) -> Int32 Returns the ID of the item at index
idx
.func getItemIndex(id: Int32
) -> Int32 Returns the index of the item with the given
id
.func getItemMetadata(idx: Int32
) -> Variant Retrieves the metadata of an item. Metadata may be any type and can be used to store extra information about an item, such as an external string ID.
func getItemText(idx: Int32
) -> String Returns the text of the item at index
idx
.func getItemTooltip(idx: Int32
) -> String Returns the tooltip of the item at index
idx
.func getPopup(
) -> PopupMenu? Returns the
PopupMenu
contained in this button.func getSelectableItem(fromLast: Bool
) -> Int32 Returns the index of the first item which is not disabled, or marked as a separator. If
fromLast
istrue
, the items will be searched in reverse order.func getSelected(
) -> Int32 func getSelectedId(
) -> Int32 Returns the ID of the selected item, or
-1
if no item is selected.func getSelectedMetadata(
) -> Variant Gets the metadata of the selected item. Metadata for items can be set using
setItemMetadata(idx:metadata:)
.func hasSelectableItems(
) -> Bool Returns
true
if this button contains at least one item which is not disabled, or marked as a separator.func isItemDisabled(idx: Int32
) -> Bool Returns
true
if the item at indexidx
is disabled.func isItemSeparator(idx: Int32
) -> Bool Returns
true
if the item at indexidx
is marked as a separator.func removeItem(idx: Int32
) Removes the item at index
idx
.func select(idx: Int32
) Selects an item by index and makes it the current item. This will work even if the item is disabled.
func setDisableShortcuts(disabled: Bool
) If
true
, shortcuts are disabled and cannot be used to trigger the button.func setItemDisabled(idx: Int32, disabled: Bool
) Sets whether the item at index
idx
is disabled.func setItemIcon(idx: Int32, texture: Texture2D?
) Sets the icon of the item at index
idx
.func setItemId(idx: Int32, id: Int32
) Sets the ID of the item at index
idx
.func setItemMetadata(idx: Int32, metadata: Variant
) Sets the metadata of an item. Metadata may be of any type and can be used to store extra information about an item, such as an external string ID.
func setItemText(idx: Int32, text: String
) Sets the text of the item at index
idx
.func setItemTooltip(idx: Int32, tooltip: String
) Sets the tooltip of the item at index
idx
.func showPopup(
) Adjusts popup position and sizing for the
OptionButton
, then shows thePopupMenu
. Prefer this over usingget_popup().popup()
.
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 (_ index: 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:_:)