mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Expose PopupMenu get_item_multistate(), get_item_multistate_max() and set_item_multistate_max()
This commit is contained in:
@@ -133,8 +133,25 @@
|
||||
<param index="4" name="accel" type="int" enum="Key" default="0" />
|
||||
<description>
|
||||
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]. Each press or activate of the item will increase the state by one. The default value is defined by [param default_state].
|
||||
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.
|
||||
[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.
|
||||
Example usage:
|
||||
[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]
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_radio_check_item">
|
||||
@@ -266,6 +283,20 @@
|
||||
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.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_item_multistate" qualifiers="const">
|
||||
<return type="int" />
|
||||
<param index="0" name="index" type="int" />
|
||||
<description>
|
||||
Returns the state of the item at the given [param index].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_item_multistate_max" qualifiers="const">
|
||||
<return type="int" />
|
||||
<param index="0" name="index" type="int" />
|
||||
<description>
|
||||
Returns the max states of the item at the given [param index].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_item_shortcut" qualifiers="const">
|
||||
<return type="Shortcut" />
|
||||
<param index="0" name="index" type="int" />
|
||||
@@ -489,6 +520,14 @@
|
||||
Sets the state of a multistate item. See [method add_multistate_item] for details.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_item_multistate_max">
|
||||
<return type="void" />
|
||||
<param index="0" name="index" type="int" />
|
||||
<param index="1" name="max_states" type="int" />
|
||||
<description>
|
||||
Sets the max states of a multistate item. See [method add_multistate_item] for details.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_item_shortcut">
|
||||
<return type="void" />
|
||||
<param index="0" name="index" type="int" />
|
||||
|
||||
Reference in New Issue
Block a user