Debian Codegraph @

doc/classes/PopupMenu.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="PopupMenu" inherits="Popup" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A modal window used to display a list of options.
5 </brief_description>
6 <description>
7 [PopupMenu] is a modal window used to display a list of options. Useful for toolbars and context menus.
8 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.
9 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.
10 [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].
11 [b]Note:[/b] [PopupMenu] is invisible by default. To make it visible, call one of the [code]popup_*[/code] methods from [Window] on the node, such as [method Window.popup_centered_clamped].
12 [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].
13 </description>
14 <tutorials>
15 </tutorials>
16 <methods>
17 <method name="activate_item_by_event">
18 <return type="bool" />
19 <param index="0" name="event" type="InputEvent" />
20 <param index="1" name="for_global_only" type="bool" default="false" />
21 <description>
22 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.
23 Returns [code]true[/code] if an item was successfully activated.
24 [b]Note:[/b] Certain [Control]s, such as [MenuButton], will call this method automatically.
25 </description>
26 </method>
27 <method name="add_check_item">
28 <return type="void" />
29 <param index="0" name="label" type="String" />
30 <param index="1" name="id" type="int" default="-1" />
31 <param index="2" name="accel" type="int" enum="Key" default="0" />
32 <description>
33 Adds a new checkable item with text [param label].
34 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.
35 [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.
36 </description>
37 </method>
38 <method name="add_check_shortcut">
39 <return type="void" />
40 <param index="0" name="shortcut" type="Shortcut" />
41 <param index="1" name="id" type="int" default="-1" />
42 <param index="2" name="global" type="bool" default="false" />
43 <description>
44 Adds a new checkable item and assigns the specified [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name.
45 An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index.
46 [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.
47 </description>
48 </method>
49 <method name="add_icon_check_item">
50 <return type="void" />
51 <param index="0" name="texture" type="Texture2D" />
52 <param index="1" name="label" type="String" />
53 <param index="2" name="id" type="int" default="-1" />
54 <param index="3" name="accel" type="int" enum="Key" default="0" />
55 <description>
56 Adds a new checkable item with text [param label] and icon [param texture].
57 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.
58 [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.
59 </description>
60 </method>
61 <method name="add_icon_check_shortcut">
62 <return type="void" />
63 <param index="0" name="texture" type="Texture2D" />
64 <param index="1" name="shortcut" type="Shortcut" />
65 <param index="2" name="id" type="int" default="-1" />
66 <param index="3" name="global" type="bool" default="false" />
67 <description>
68 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.
69 An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index.
70 [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.
71 </description>
72 </method>
73 <method name="add_icon_item">
74 <return type="void" />
75 <param index="0" name="texture" type="Texture2D" />
76 <param index="1" name="label" type="String" />
77 <param index="2" name="id" type="int" default="-1" />
78 <param index="3" name="accel" type="int" enum="Key" default="0" />
79 <description>
80 Adds a new item with text [param label] and icon [param texture].
81 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.
82 </description>
83 </method>
84 <method name="add_icon_radio_check_item">
85 <return type="void" />
86 <param index="0" name="texture" type="Texture2D" />
87 <param index="1" name="label" type="String" />
88 <param index="2" name="id" type="int" default="-1" />
89 <param index="3" name="accel" type="int" enum="Key" default="0" />
90 <description>
91 Same as [method add_icon_check_item], but uses a radio check button.
92 </description>
93 </method>
94 <method name="add_icon_radio_check_shortcut">
95 <return type="void" />
96 <param index="0" name="texture" type="Texture2D" />
97 <param index="1" name="shortcut" type="Shortcut" />
98 <param index="2" name="id" type="int" default="-1" />
99 <param index="3" name="global" type="bool" default="false" />
100 <description>
101 Same as [method add_icon_check_shortcut], but uses a radio check button.
102 </description>
103 </method>
104 <method name="add_icon_shortcut">
105 <return type="void" />
106 <param index="0" name="texture" type="Texture2D" />
107 <param index="1" name="shortcut" type="Shortcut" />
108 <param index="2" name="id" type="int" default="-1" />
109 <param index="3" name="global" type="bool" default="false" />
110 <param index="4" name="allow_echo" type="bool" default="false" />
111 <description>
112 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.
113 An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index.
114 If [param allow_echo] is [code]true[/code], the shortcut can be activated with echo events.
115 </description>
116 </method>
117 <method name="add_item">
118 <return type="void" />
119 <param index="0" name="label" type="String" />
120 <param index="1" name="id" type="int" default="-1" />
121 <param index="2" name="accel" type="int" enum="Key" default="0" />
122 <description>
123 Adds a new item with text [param label].
124 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.
125 [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].
126 </description>
127 </method>
128 <method name="add_multistate_item">
129 <return type="void" />
130 <param index="0" name="label" type="String" />
131 <param index="1" name="max_states" type="int" />
132 <param index="2" name="default_state" type="int" default="0" />
133 <param index="3" name="id" type="int" default="-1" />
134 <param index="4" name="accel" type="int" enum="Key" default="0" />
135 <description>
136 Adds a new multistate item with text [param label].
137 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].
138 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.
139 [codeblock]
140 func _ready():
141 add_multistate_item("Item", 3, 0)
142
143 index_pressed.connect(func(index: int):
144 toggle_item_multistate(index)
145 match get_item_multistate(index):
146 0:
147 print("First state")
148 1:
149 print("Second state")
150 2:
151 print("Third state")
152 )
153 [/codeblock]
154 [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.
155 </description>
156 </method>
157 <method name="add_radio_check_item">
158 <return type="void" />
159 <param index="0" name="label" type="String" />
160 <param index="1" name="id" type="int" default="-1" />
161 <param index="2" name="accel" type="int" enum="Key" default="0" />
162 <description>
163 Adds a new radio check button with text [param label].
164 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.
165 [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.
166 </description>
167 </method>
168 <method name="add_radio_check_shortcut">
169 <return type="void" />
170 <param index="0" name="shortcut" type="Shortcut" />
171 <param index="1" name="id" type="int" default="-1" />
172 <param index="2" name="global" type="bool" default="false" />
173 <description>
174 Adds a new radio check button and assigns a [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name.
175 An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index.
176 [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.
177 </description>
178 </method>
179 <method name="add_separator">
180 <return type="void" />
181 <param index="0" name="label" type="String" default="&quot;&quot;" />
182 <param index="1" name="id" type="int" default="-1" />
183 <description>
184 Adds a separator between items. Separators also occupy an index, which you can set by using the [param id] parameter.
185 A [param label] can optionally be provided, which will appear at the center of the separator.
186 </description>
187 </method>
188 <method name="add_shortcut">
189 <return type="void" />
190 <param index="0" name="shortcut" type="Shortcut" />
191 <param index="1" name="id" type="int" default="-1" />
192 <param index="2" name="global" type="bool" default="false" />
193 <param index="3" name="allow_echo" type="bool" default="false" />
194 <description>
195 Adds a [Shortcut].
196 An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index.
197 If [param allow_echo] is [code]true[/code], the shortcut can be activated with echo events.
198 </description>
199 </method>
200 <method name="add_submenu_item" deprecated="Prefer using [method add_submenu_node_item] instead.">
201 <return type="void" />
202 <param index="0" name="label" type="String" />
203 <param index="1" name="submenu" type="String" />
204 <param index="2" name="id" type="int" default="-1" />
205 <description>
206 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.
207 An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index.
208 </description>
209 </method>
210 <method name="add_submenu_node_item">
211 <return type="void" />
212 <param index="0" name="label" type="String" />
213 <param index="1" name="submenu" type="PopupMenu" />
214 <param index="2" name="id" type="int" default="-1" />
215 <description>
216 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.
217 [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.
218 An [param id] can optionally be provided. If no [param id] is provided, one will be created from the index.
219 </description>
220 </method>
221 <method name="clear">
222 <return type="void" />
223 <param index="0" name="free_submenus" type="bool" default="false" />
224 <description>
225 Removes all items from the [PopupMenu]. If [param free_submenus] is [code]true[/code], the submenu nodes are automatically freed.
226 </description>
227 </method>
228 <method name="get_focused_item" qualifiers="const">
229 <return type="int" />
230 <description>
231 Returns the index of the currently focused item. Returns [code]-1[/code] if no item is focused.
232 </description>
233 </method>
234 <method name="get_item_accelerator" qualifiers="const">
235 <return type="int" enum="Key" />
236 <param index="0" name="index" type="int" />
237 <description>
238 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]).
239 </description>
240 </method>
241 <method name="get_item_auto_translate_mode" qualifiers="const">
242 <return type="int" enum="Node.AutoTranslateMode" />
243 <param index="0" name="index" type="int" />
244 <description>
245 Returns the auto translate mode of the item at the given [param index].
246 </description>
247 </method>
248 <method name="get_item_icon" qualifiers="const">
249 <return type="Texture2D" />
250 <param index="0" name="index" type="int" />
251 <description>
252 Returns the icon of the item at the given [param index].
253 </description>
254 </method>
255 <method name="get_item_icon_max_width" qualifiers="const">
256 <return type="int" />
257 <param index="0" name="index" type="int" />
258 <description>
259 Returns the maximum allowed width of the icon for the item at the given [param index].
260 </description>
261 </method>
262 <method name="get_item_icon_modulate" qualifiers="const">
263 <return type="Color" />
264 <param index="0" name="index" type="int" />
265 <description>
266 Returns a [Color] modulating the item's icon at the given [param index].
267 </description>
268 </method>
269 <method name="get_item_id" qualifiers="const">
270 <return type="int" />
271 <param index="0" name="index" type="int" />
272 <description>
273 Returns the ID of the item at the given [param index]. [code]id[/code] can be manually assigned, while index can not.
274 </description>
275 </method>
276 <method name="get_item_indent" qualifiers="const">
277 <return type="int" />
278 <param index="0" name="index" type="int" />
279 <description>
280 Returns the horizontal offset of the item at the given [param index].
281 </description>
282 </method>
283 <method name="get_item_index" qualifiers="const">
284 <return type="int" />
285 <param index="0" name="id" type="int" />
286 <description>
287 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.
288 </description>
289 </method>
290 <method name="get_item_language" qualifiers="const">
291 <return type="String" />
292 <param index="0" name="index" type="int" />
293 <description>
294 Returns item's text language code.
295 </description>
296 </method>
297 <method name="get_item_metadata" qualifiers="const">
298 <return type="Variant" />
299 <param index="0" name="index" type="int" />
300 <description>
301 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.
302 </description>
303 </method>
304 <method name="get_item_multistate" qualifiers="const">
305 <return type="int" />
306 <param index="0" name="index" type="int" />
307 <description>
308 Returns the state of the item at the given [param index].
309 </description>
310 </method>
311 <method name="get_item_multistate_max" qualifiers="const">
312 <return type="int" />
313 <param index="0" name="index" type="int" />
314 <description>
315 Returns the max states of the item at the given [param index].
316 </description>
317 </method>
318 <method name="get_item_shortcut" qualifiers="const">
319 <return type="Shortcut" />
320 <param index="0" name="index" type="int" />
321 <description>
322 Returns the [Shortcut] associated with the item at the given [param index].
323 </description>
324 </method>
325 <method name="get_item_submenu" qualifiers="const" deprecated="Prefer using [method get_item_submenu_node] instead.">
326 <return type="String" />
327 <param index="0" name="index" type="int" />
328 <description>
329 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.
330 </description>
331 </method>
332 <method name="get_item_submenu_node" qualifiers="const">
333 <return type="PopupMenu" />
334 <param index="0" name="index" type="int" />
335 <description>
336 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.
337 </description>
338 </method>
339 <method name="get_item_text" qualifiers="const">
340 <return type="String" />
341 <param index="0" name="index" type="int" />
342 <description>
343 Returns the text of the item at the given [param index].
344 </description>
345 </method>
346 <method name="get_item_text_direction" qualifiers="const">
347 <return type="int" enum="Control.TextDirection" />
348 <param index="0" name="index" type="int" />
349 <description>
350 Returns item's text base writing direction.
351 </description>
352 </method>
353 <method name="get_item_tooltip" qualifiers="const">
354 <return type="String" />
355 <param index="0" name="index" type="int" />
356 <description>
357 Returns the tooltip associated with the item at the given [param index].
358 </description>
359 </method>
360 <method name="is_item_checkable" qualifiers="const">
361 <return type="bool" />
362 <param index="0" name="index" type="int" />
363 <description>
364 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.
365 [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.
366 </description>
367 </method>
368 <method name="is_item_checked" qualifiers="const">
369 <return type="bool" />
370 <param index="0" name="index" type="int" />
371 <description>
372 Returns [code]true[/code] if the item at the given [param index] is checked.
373 </description>
374 </method>
375 <method name="is_item_disabled" qualifiers="const">
376 <return type="bool" />
377 <param index="0" name="index" type="int" />
378 <description>
379 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.
380 See [method set_item_disabled] for more info on how to disable an item.
381 </description>
382 </method>
383 <method name="is_item_radio_checkable" qualifiers="const">
384 <return type="bool" />
385 <param index="0" name="index" type="int" />
386 <description>
387 Returns [code]true[/code] if the item at the given [param index] has radio button-style checkability.
388 [b]Note:[/b] This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
389 </description>
390 </method>
391 <method name="is_item_separator" qualifiers="const">
392 <return type="bool" />
393 <param index="0" name="index" type="int" />
394 <description>
395 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.
396 </description>
397 </method>
398 <method name="is_item_shortcut_disabled" qualifiers="const">
399 <return type="bool" />
400 <param index="0" name="index" type="int" />
401 <description>
402 Returns [code]true[/code] if the specified item's shortcut is disabled.
403 </description>
404 </method>
405 <method name="is_native_menu" qualifiers="const">
406 <return type="bool" />
407 <description>
408 Returns [code]true[/code] if the system native menu is supported and currently used by this [PopupMenu].
409 </description>
410 </method>
411 <method name="is_system_menu" qualifiers="const">
412 <return type="bool" />
413 <description>
414 Returns [code]true[/code] if the menu is bound to the special system menu.
415 </description>
416 </method>
417 <method name="remove_item">
418 <return type="void" />
419 <param index="0" name="index" type="int" />
420 <description>
421 Removes the item at the given [param index] from the menu.
422 [b]Note:[/b] The indices of items after the removed item will be shifted by one.
423 </description>
424 </method>
425 <method name="scroll_to_item">
426 <return type="void" />
427 <param index="0" name="index" type="int" />
428 <description>
429 Moves the scroll view to make the item at the given [param index] visible.
430 </description>
431 </method>
432 <method name="set_focused_item">
433 <return type="void" />
434 <param index="0" name="index" type="int" />
435 <description>
436 Sets the currently focused item as the given [param index].
437 Passing [code]-1[/code] as the index makes so that no item is focused.
438 </description>
439 </method>
440 <method name="set_item_accelerator">
441 <return type="void" />
442 <param index="0" name="index" type="int" />
443 <param index="1" name="accel" type="int" enum="Key" />
444 <description>
445 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]).
446 </description>
447 </method>
448 <method name="set_item_as_checkable">
449 <return type="void" />
450 <param index="0" name="index" type="int" />
451 <param index="1" name="enable" type="bool" />
452 <description>
453 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.
454 [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
455 </description>
456 </method>
457 <method name="set_item_as_radio_checkable">
458 <return type="void" />
459 <param index="0" name="index" type="int" />
460 <param index="1" name="enable" type="bool" />
461 <description>
462 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.
463 </description>
464 </method>
465 <method name="set_item_as_separator">
466 <return type="void" />
467 <param index="0" name="index" type="int" />
468 <param index="1" name="enable" type="bool" />
469 <description>
470 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.
471 </description>
472 </method>
473 <method name="set_item_auto_translate_mode">
474 <return type="void" />
475 <param index="0" name="index" type="int" />
476 <param index="1" name="mode" type="int" enum="Node.AutoTranslateMode" />
477 <description>
478 Sets the auto translate mode of the item at the given [param index].
479 Items use [constant Node.AUTO_TRANSLATE_MODE_INHERIT] by default, which uses the same auto translate mode as the [PopupMenu] itself.
480 </description>
481 </method>
482 <method name="set_item_checked">
483 <return type="void" />
484 <param index="0" name="index" type="int" />
485 <param index="1" name="checked" type="bool" />
486 <description>
487 Sets the checkstate status of the item at the given [param index].
488 </description>
489 </method>
490 <method name="set_item_disabled">
491 <return type="void" />
492 <param index="0" name="index" type="int" />
493 <param index="1" name="disabled" type="bool" />
494 <description>
495 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.
496 </description>
497 </method>
498 <method name="set_item_icon">
499 <return type="void" />
500 <param index="0" name="index" type="int" />
501 <param index="1" name="icon" type="Texture2D" />
502 <description>
503 Replaces the [Texture2D] icon of the item at the given [param index].
504 </description>
505 </method>
506 <method name="set_item_icon_max_width">
507 <return type="void" />
508 <param index="0" name="index" type="int" />
509 <param index="1" name="width" type="int" />
510 <description>
511 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.
512 </description>
513 </method>
514 <method name="set_item_icon_modulate">
515 <return type="void" />
516 <param index="0" name="index" type="int" />
517 <param index="1" name="modulate" type="Color" />
518 <description>
519 Sets a modulating [Color] of the item's icon at the given [param index].
520 </description>
521 </method>
522 <method name="set_item_id">
523 <return type="void" />
524 <param index="0" name="index" type="int" />
525 <param index="1" name="id" type="int" />
526 <description>
527 Sets the [param id] of the item at the given [param index].
528 The [param id] is used in [signal id_pressed] and [signal id_focused] signals.
529 </description>
530 </method>
531 <method name="set_item_indent">
532 <return type="void" />
533 <param index="0" name="index" type="int" />
534 <param index="1" name="indent" type="int" />
535 <description>
536 Sets the horizontal offset of the item at the given [param index].
537 </description>
538 </method>
539 <method name="set_item_language">
540 <return type="void" />
541 <param index="0" name="index" type="int" />
542 <param index="1" name="language" type="String" />
543 <description>
544 Sets the language code of the text for the item at the given index to [param language]. This is used for line-breaking and text shaping algorithms. If [param language] is empty, the current locale is used.
545 </description>
546 </method>
547 <method name="set_item_metadata">
548 <return type="void" />
549 <param index="0" name="index" type="int" />
550 <param index="1" name="metadata" type="Variant" />
551 <description>
552 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.
553 </description>
554 </method>
555 <method name="set_item_multistate">
556 <return type="void" />
557 <param index="0" name="index" type="int" />
558 <param index="1" name="state" type="int" />
559 <description>
560 Sets the state of a multistate item. See [method add_multistate_item] for details.
561 </description>
562 </method>
563 <method name="set_item_multistate_max">
564 <return type="void" />
565 <param index="0" name="index" type="int" />
566 <param index="1" name="max_states" type="int" />
567 <description>
568 Sets the max states of a multistate item. See [method add_multistate_item] for details.
569 </description>
570 </method>
571 <method name="set_item_shortcut">
572 <return type="void" />
573 <param index="0" name="index" type="int" />
574 <param index="1" name="shortcut" type="Shortcut" />
575 <param index="2" name="global" type="bool" default="false" />
576 <description>
577 Sets a [Shortcut] for the item at the given [param index].
578 </description>
579 </method>
580 <method name="set_item_shortcut_disabled">
581 <return type="void" />
582 <param index="0" name="index" type="int" />
583 <param index="1" name="disabled" type="bool" />
584 <description>
585 Disables the [Shortcut] of the item at the given [param index].
586 </description>
587 </method>
588 <method name="set_item_submenu" deprecated="Prefer using [method set_item_submenu_node] instead.">
589 <return type="void" />
590 <param index="0" name="index" type="int" />
591 <param index="1" name="submenu" type="String" />
592 <description>
593 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.
594 </description>
595 </method>
596 <method name="set_item_submenu_node">
597 <return type="void" />
598 <param index="0" name="index" type="int" />
599 <param index="1" name="submenu" type="PopupMenu" />
600 <description>
601 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.
602 </description>
603 </method>
604 <method name="set_item_text">
605 <return type="void" />
606 <param index="0" name="index" type="int" />
607 <param index="1" name="text" type="String" />
608 <description>
609 Sets the text of the item at the given [param index].
610 </description>
611 </method>
612 <method name="set_item_text_direction">
613 <return type="void" />
614 <param index="0" name="index" type="int" />
615 <param index="1" name="direction" type="int" enum="Control.TextDirection" />
616 <description>
617 Sets item's text base writing direction.
618 </description>
619 </method>
620 <method name="set_item_tooltip">
621 <return type="void" />
622 <param index="0" name="index" type="int" />
623 <param index="1" name="tooltip" type="String" />
624 <description>
625 Sets the [String] tooltip of the item at the given [param index].
626 </description>
627 </method>
628 <method name="toggle_item_checked">
629 <return type="void" />
630 <param index="0" name="index" type="int" />
631 <description>
632 Toggles the check state of the item at the given [param index].
633 </description>
634 </method>
635 <method name="toggle_item_multistate">
636 <return type="void" />
637 <param index="0" name="index" type="int" />
638 <description>
639 Cycle to the next state of a multistate item. See [method add_multistate_item] for details.
640 </description>
641 </method>
642 </methods>
643 <members>
644 <member name="allow_search" type="bool" setter="set_allow_search" getter="get_allow_search" default="true">
645 If [code]true[/code], allows navigating [PopupMenu] with letter keys.
646 </member>
647 <member name="hide_on_checkable_item_selection" type="bool" setter="set_hide_on_checkable_item_selection" getter="is_hide_on_checkable_item_selection" default="true">
648 If [code]true[/code], hides the [PopupMenu] when a checkbox or radio button is selected.
649 </member>
650 <member name="hide_on_item_selection" type="bool" setter="set_hide_on_item_selection" getter="is_hide_on_item_selection" default="true">
651 If [code]true[/code], hides the [PopupMenu] when an item is selected.
652 </member>
653 <member name="hide_on_state_item_selection" type="bool" setter="set_hide_on_state_item_selection" getter="is_hide_on_state_item_selection" default="false">
654 If [code]true[/code], hides the [PopupMenu] when a state item is selected.
655 </member>
656 <member name="item_count" type="int" setter="set_item_count" getter="get_item_count" default="0">
657 The number of items currently in the list.
658 </member>
659 <member name="prefer_native_menu" type="bool" setter="set_prefer_native_menu" getter="is_prefer_native_menu" default="false">
660 If [code]true[/code], [MenuBar] will use native menu when supported.
661 [b]Note:[/b] If [PopupMenu] is linked to [StatusIndicator], [MenuBar], or another [PopupMenu] item it can use native menu regardless of this property, use [method is_native_menu] to check it.
662 </member>
663 <member name="shrink_height" type="bool" setter="set_shrink_height" getter="get_shrink_height" default="true">
664 If [code]true[/code], shrinks [PopupMenu] to minimum height when it's shown.
665 </member>
666 <member name="shrink_width" type="bool" setter="set_shrink_width" getter="get_shrink_width" default="true">
667 If [code]true[/code], shrinks [PopupMenu] to minimum width when it's shown.
668 </member>
669 <member name="submenu_popup_delay" type="float" setter="set_submenu_popup_delay" getter="get_submenu_popup_delay" default="0.2">
670 Sets the delay time in seconds for the submenu item to popup on mouse hovering. If the popup menu is added as a child of another (acting as a submenu), it will inherit the delay time of the parent menu item.
671 [b]Note:[/b] If the mouse is exiting a submenu item with an open submenu and enters a different submenu item, the submenu popup delay time is affected by the direction of the mouse movement toward the open submenu. If the mouse is moving toward the submenu, the open submenu will wait approximately [code]0.5[/code] seconds before closing, which then allows the hovered submenu item to open. This additional delay allows the mouse time to move to the open submenu across other menu items without prematurely closing. If the mouse is not moving toward the open submenu, for example in a downward direction, the open submenu will close immediately.
672 </member>
673 <member name="system_menu_id" type="int" setter="set_system_menu" getter="get_system_menu" enum="NativeMenu.SystemMenus" default="0">
674 If set to one of the values of [enum NativeMenu.SystemMenus], this [PopupMenu] is bound to the special system menu. Only one [PopupMenu] can be bound to each special menu at a time.
675 </member>
676 <member name="transparent" type="bool" setter="set_flag" getter="get_flag" overrides="Window" default="true" />
677 <member name="transparent_bg" type="bool" setter="set_transparent_background" getter="has_transparent_background" overrides="Viewport" default="true" />
678 </members>
679 <signals>
680 <signal name="id_focused">
681 <param index="0" name="id" type="int" />
682 <description>
683 Emitted when the user navigated to an item of some [param id] using the [member ProjectSettings.input/ui_up] or [member ProjectSettings.input/ui_down] input action.
684 </description>
685 </signal>
686 <signal name="id_pressed">
687 <param index="0" name="id" type="int" />
688 <description>
689 Emitted when an item of some [param id] is pressed. Also emitted when its accelerator is activated on macOS.
690 [b]Note:[/b] If [param id] is negative (either explicitly or due to overflow), this will return the corresponding index instead.
691 </description>
692 </signal>
693 <signal name="index_pressed">
694 <param index="0" name="index" type="int" />
695 <description>
696 Emitted when an item of some [param index] is pressed. Also emitted when its accelerator is activated on macOS.
697 </description>
698 </signal>
699 <signal name="menu_changed">
700 <description>
701 Emitted when any item is added, modified or removed.
702 </description>
703 </signal>
704 </signals>
705 <theme_items>
706 <theme_item name="font_accelerator_color" data_type="color" type="Color" default="Color(0.7, 0.7, 0.7, 0.8)">
707 The text [Color] used for shortcuts and accelerators that show next to the menu item name when defined. See [method get_item_accelerator] for more info on accelerators.
708 </theme_item>
709 <theme_item name="font_color" data_type="color" type="Color" default="Color(0.875, 0.875, 0.875, 1)">
710 The default text [Color] for menu items' names.
711 </theme_item>
712 <theme_item name="font_disabled_color" data_type="color" type="Color" default="Color(0.4, 0.4, 0.4, 0.8)">
713 [Color] used for disabled menu items' text.
714 </theme_item>
715 <theme_item name="font_hover_color" data_type="color" type="Color" default="Color(0.875, 0.875, 0.875, 1)">
716 [Color] used for the hovered text.
717 </theme_item>
718 <theme_item name="font_outline_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)">
719 The tint of text outline of the menu item.
720 </theme_item>
721 <theme_item name="font_separator_color" data_type="color" type="Color" default="Color(0.875, 0.875, 0.875, 1)">
722 [Color] used for labeled separators' text. See [method add_separator].
723 </theme_item>
724 <theme_item name="font_separator_outline_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)">
725 The tint of text outline of the labeled separator.
726 </theme_item>
727 <theme_item name="gutter_compact" data_type="constant" type="int" default="1">
728 If not [code]0[/code], the icon gutter will be merged with the checkbox gutter when possible. This acts as a boolean.
729 </theme_item>
730 <theme_item name="h_separation" data_type="constant" type="int" default="4">
731 The horizontal space between the item's elements.
732 </theme_item>
733 <theme_item name="icon_max_width" data_type="constant" type="int" default="0">
734 The maximum allowed width of the item's icon. This limit is applied on top of the default size of the icon, but before the value set with [method set_item_icon_max_width]. The height is adjusted according to the icon's ratio.
735 </theme_item>
736 <theme_item name="indent" data_type="constant" type="int" default="10">
737 Width of the single indentation level.
738 </theme_item>
739 <theme_item name="item_end_padding" data_type="constant" type="int" default="2">
740 Horizontal padding to the right of the items (or left, in RTL layout).
741 </theme_item>
742 <theme_item name="item_start_padding" data_type="constant" type="int" default="2">
743 Horizontal padding to the left of the items (or right, in RTL layout).
744 </theme_item>
745 <theme_item name="outline_size" data_type="constant" type="int" default="0">
746 The size of the item text outline.
747 [b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.
748 </theme_item>
749 <theme_item name="separator_outline_size" data_type="constant" type="int" default="0">
750 The size of the labeled separator text outline.
751 </theme_item>
752 <theme_item name="v_separation" data_type="constant" type="int" default="4">
753 The vertical space between each menu item.
754 </theme_item>
755 <theme_item name="font" data_type="font" type="Font">
756 [Font] used for the menu items.
757 </theme_item>
758 <theme_item name="font_separator" data_type="font" type="Font">
759 [Font] used for the labeled separator.
760 </theme_item>
761 <theme_item name="font_separator_size" data_type="font_size" type="int">
762 Font size of the labeled separator.
763 </theme_item>
764 <theme_item name="font_size" data_type="font_size" type="int">
765 Font size of the menu items.
766 </theme_item>
767 <theme_item name="checked" data_type="icon" type="Texture2D">
768 [Texture2D] icon for the checked checkbox items.
769 </theme_item>
770 <theme_item name="checked_disabled" data_type="icon" type="Texture2D">
771 [Texture2D] icon for the checked checkbox items when they are disabled.
772 </theme_item>
773 <theme_item name="radio_checked" data_type="icon" type="Texture2D">
774 [Texture2D] icon for the checked radio button items.
775 </theme_item>
776 <theme_item name="radio_checked_disabled" data_type="icon" type="Texture2D">
777 [Texture2D] icon for the checked radio button items when they are disabled.
778 </theme_item>
779 <theme_item name="radio_unchecked" data_type="icon" type="Texture2D">
780 [Texture2D] icon for the unchecked radio button items.
781 </theme_item>
782 <theme_item name="radio_unchecked_disabled" data_type="icon" type="Texture2D">
783 [Texture2D] icon for the unchecked radio button items when they are disabled.
784 </theme_item>
785 <theme_item name="submenu" data_type="icon" type="Texture2D">
786 [Texture2D] icon for the submenu arrow (for left-to-right layouts).
787 </theme_item>
788 <theme_item name="submenu_mirrored" data_type="icon" type="Texture2D">
789 [Texture2D] icon for the submenu arrow (for right-to-left layouts).
790 </theme_item>
791 <theme_item name="unchecked" data_type="icon" type="Texture2D">
792 [Texture2D] icon for the unchecked checkbox items.
793 </theme_item>
794 <theme_item name="unchecked_disabled" data_type="icon" type="Texture2D">
795 [Texture2D] icon for the unchecked checkbox items when they are disabled.
796 </theme_item>
797 <theme_item name="hover" data_type="style" type="StyleBox">
798 [StyleBox] displayed when the [PopupMenu] item is hovered.
799 </theme_item>
800 <theme_item name="labeled_separator_left" data_type="style" type="StyleBox">
801 [StyleBox] for the left side of labeled separator. See [method add_separator].
802 </theme_item>
803 <theme_item name="labeled_separator_right" data_type="style" type="StyleBox">
804 [StyleBox] for the right side of labeled separator. See [method add_separator].
805 </theme_item>
806 <theme_item name="panel" data_type="style" type="StyleBox">
807 [StyleBox] for the background panel.
808 </theme_item>
809 <theme_item name="separator" data_type="style" type="StyleBox">
810 [StyleBox] used for the separators. See [method add_separator].
811 </theme_item>
812 </theme_items>
813 </class>