Skip to content

Commit e53e357

Browse files
authored
Merge pull request #55725 from KoBeWi/id(x)
Improve PopupMenu doc about id and index
2 parents 04fac59 + 347e50f commit e53e357

File tree

2 files changed

+109
-107
lines changed

2 files changed

+109
-107
lines changed

doc/classes/PopupMenu.xml

Lines changed: 68 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<description>
108108
Adds a new item with text [code]label[/code].
109109
An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
110+
[b]Note:[/b] The provided [code]id[/code] 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].
110111
</description>
111112
</method>
112113
<method name="add_multistate_item">
@@ -181,7 +182,7 @@
181182
</method>
182183
<method name="clear_item_opentype_features">
183184
<return type="void" />
184-
<argument index="0" name="idx" type="int" />
185+
<argument index="0" name="index" type="int" />
185186
<description>
186187
Removes all OpenType features form the item's text.
187188
</description>
@@ -194,234 +195,235 @@
194195
</method>
195196
<method name="get_item_accelerator" qualifiers="const">
196197
<return type="int" enum="Key" />
197-
<argument index="0" name="idx" type="int" />
198+
<argument index="0" name="index" type="int" />
198199
<description>
199-
Returns the accelerator of the item at index [code]idx[/code]. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
200+
Returns the accelerator of the item at the given [code]index[/code]. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
200201
</description>
201202
</method>
202203
<method name="get_item_icon" qualifiers="const">
203204
<return type="Texture2D" />
204-
<argument index="0" name="idx" type="int" />
205+
<argument index="0" name="index" type="int" />
205206
<description>
206-
Returns the icon of the item at index [code]idx[/code].
207+
Returns the icon of the item at the given [code]index[/code].
207208
</description>
208209
</method>
209210
<method name="get_item_id" qualifiers="const">
210211
<return type="int" />
211-
<argument index="0" name="idx" type="int" />
212+
<argument index="0" name="index" type="int" />
212213
<description>
213-
Returns the id of the item at index [code]idx[/code]. [code]id[/code] can be manually assigned, while index can not.
214+
Returns the id of the item at the given [code]index[/code]. [code]id[/code] can be manually assigned, while index can not.
214215
</description>
215216
</method>
216217
<method name="get_item_index" qualifiers="const">
217218
<return type="int" />
218219
<argument index="0" name="id" type="int" />
219220
<description>
220-
Returns the index of the item containing the specified [code]id[/code]. Index is automatically assigned to each item by the engine. Index can not be set manually.
221+
Returns the index of the item containing the specified [code]id[/code]. Index is automatically assigned to each item by the engine and can not be set manually.
221222
</description>
222223
</method>
223224
<method name="get_item_language" qualifiers="const">
224225
<return type="String" />
225-
<argument index="0" name="idx" type="int" />
226+
<argument index="0" name="index" type="int" />
226227
<description>
227228
Returns item's text language code.
228229
</description>
229230
</method>
230231
<method name="get_item_metadata" qualifiers="const">
231232
<return type="Variant" />
232-
<argument index="0" name="idx" type="int" />
233+
<argument index="0" name="index" type="int" />
233234
<description>
234235
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.
235236
</description>
236237
</method>
237238
<method name="get_item_opentype_feature" qualifiers="const">
238239
<return type="int" />
239-
<argument index="0" name="idx" type="int" />
240+
<argument index="0" name="index" type="int" />
240241
<argument index="1" name="tag" type="String" />
241242
<description>
242243
Returns OpenType feature [code]tag[/code] of the item's text.
243244
</description>
244245
</method>
245246
<method name="get_item_shortcut" qualifiers="const">
246247
<return type="Shortcut" />
247-
<argument index="0" name="idx" type="int" />
248+
<argument index="0" name="index" type="int" />
248249
<description>
249-
Returns the [Shortcut] associated with the specified [code]idx[/code] item.
250+
Returns the [Shortcut] associated with the item at the given [code]index[/code].
250251
</description>
251252
</method>
252253
<method name="get_item_submenu" qualifiers="const">
253254
<return type="String" />
254-
<argument index="0" name="idx" type="int" />
255+
<argument index="0" name="index" type="int" />
255256
<description>
256-
Returns the submenu name of the item at index [code]idx[/code]. See [method add_submenu_item] for more info on how to add a submenu.
257+
Returns the submenu name of the item at the given [code]index[/code]. See [method add_submenu_item] for more info on how to add a submenu.
257258
</description>
258259
</method>
259260
<method name="get_item_text" qualifiers="const">
260261
<return type="String" />
261-
<argument index="0" name="idx" type="int" />
262+
<argument index="0" name="index" type="int" />
262263
<description>
263-
Returns the text of the item at index [code]idx[/code].
264+
Returns the text of the item at the given [code]index[/code].
264265
</description>
265266
</method>
266267
<method name="get_item_text_direction" qualifiers="const">
267268
<return type="int" enum="Control.TextDirection" />
268-
<argument index="0" name="idx" type="int" />
269+
<argument index="0" name="index" type="int" />
269270
<description>
270271
Returns item's text base writing direction.
271272
</description>
272273
</method>
273274
<method name="get_item_tooltip" qualifiers="const">
274275
<return type="String" />
275-
<argument index="0" name="idx" type="int" />
276+
<argument index="0" name="index" type="int" />
276277
<description>
277-
Returns the tooltip associated with the specified index index [code]idx[/code].
278+
Returns the tooltip associated with the item at the given [code]index[/code].
278279
</description>
279280
</method>
280281
<method name="is_item_checkable" qualifiers="const">
281282
<return type="bool" />
282-
<argument index="0" name="idx" type="int" />
283+
<argument index="0" name="index" type="int" />
283284
<description>
284-
Returns [code]true[/code] if the item at index [code]idx[/code] is checkable in some way, i.e. if it has a checkbox or radio button.
285+
Returns [code]true[/code] if the item at the given [code]index[/code] is checkable in some way, i.e. if it has a checkbox or radio button.
285286
[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.
286287
</description>
287288
</method>
288289
<method name="is_item_checked" qualifiers="const">
289290
<return type="bool" />
290-
<argument index="0" name="idx" type="int" />
291+
<argument index="0" name="index" type="int" />
291292
<description>
292-
Returns [code]true[/code] if the item at index [code]idx[/code] is checked.
293+
Returns [code]true[/code] if the item at the given [code]index[/code] is checked.
293294
</description>
294295
</method>
295296
<method name="is_item_disabled" qualifiers="const">
296297
<return type="bool" />
297-
<argument index="0" name="idx" type="int" />
298+
<argument index="0" name="index" type="int" />
298299
<description>
299-
Returns [code]true[/code] if the item at index [code]idx[/code] is disabled. When it is disabled it can't be selected, or its action invoked.
300+
Returns [code]true[/code] if the item at the given [code]index[/code] is disabled. When it is disabled it can't be selected, or its action invoked.
300301
See [method set_item_disabled] for more info on how to disable an item.
301302
</description>
302303
</method>
303304
<method name="is_item_radio_checkable" qualifiers="const">
304305
<return type="bool" />
305-
<argument index="0" name="idx" type="int" />
306+
<argument index="0" name="index" type="int" />
306307
<description>
307-
Returns [code]true[/code] if the item at index [code]idx[/code] has radio button-style checkability.
308+
Returns [code]true[/code] if the item at the given [code]index[/code] has radio button-style checkability.
308309
[b]Note:[/b] This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
309310
</description>
310311
</method>
311312
<method name="is_item_separator" qualifiers="const">
312313
<return type="bool" />
313-
<argument index="0" name="idx" type="int" />
314+
<argument index="0" name="index" type="int" />
314315
<description>
315316
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.
316317
</description>
317318
</method>
318319
<method name="is_item_shortcut_disabled" qualifiers="const">
319320
<return type="bool" />
320-
<argument index="0" name="idx" type="int" />
321+
<argument index="0" name="index" type="int" />
321322
<description>
322323
Returns [code]true[/code] if the specified item's shortcut is disabled.
323324
</description>
324325
</method>
325326
<method name="remove_item">
326327
<return type="void" />
327-
<argument index="0" name="idx" type="int" />
328+
<argument index="0" name="index" type="int" />
328329
<description>
329-
Removes the item at index [code]idx[/code] from the menu.
330+
Removes the item at the given [code]index[/code] from the menu.
330331
[b]Note:[/b] The indices of items after the removed item will be shifted by one.
331332
</description>
332333
</method>
333334
<method name="set_item_accelerator">
334335
<return type="void" />
335-
<argument index="0" name="idx" type="int" />
336+
<argument index="0" name="index" type="int" />
336337
<argument index="1" name="accel" type="int" enum="Key" />
337338
<description>
338-
Sets the accelerator of the item at index [code]idx[/code]. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
339+
Sets the accelerator of the item at the given [code]index[/code]. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
339340
</description>
340341
</method>
341342
<method name="set_item_as_checkable">
342343
<return type="void" />
343-
<argument index="0" name="idx" type="int" />
344+
<argument index="0" name="index" type="int" />
344345
<argument index="1" name="enable" type="bool" />
345346
<description>
346-
Sets whether the item at index [code]idx[/code] has a checkbox. If [code]false[/code], sets the type of the item to plain text.
347+
Sets whether the item at the given [code]index[/code] has a checkbox. If [code]false[/code], sets the type of the item to plain text.
347348
[b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
348349
</description>
349350
</method>
350351
<method name="set_item_as_radio_checkable">
351352
<return type="void" />
352-
<argument index="0" name="idx" type="int" />
353+
<argument index="0" name="index" type="int" />
353354
<argument index="1" name="enable" type="bool" />
354355
<description>
355-
Sets the type of the item at the specified index [code]idx[/code] to radio button. If [code]false[/code], sets the type of the item to plain text.
356+
Sets the type of the item at the given [code]index[/code] to radio button. If [code]false[/code], sets the type of the item to plain text.
356357
</description>
357358
</method>
358359
<method name="set_item_as_separator">
359360
<return type="void" />
360-
<argument index="0" name="idx" type="int" />
361+
<argument index="0" name="index" type="int" />
361362
<argument index="1" name="enable" type="bool" />
362363
<description>
363-
Mark the item at index [code]idx[/code] 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.
364+
Mark the item at the given [code]index[/code] 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.
364365
</description>
365366
</method>
366367
<method name="set_item_checked">
367368
<return type="void" />
368-
<argument index="0" name="idx" type="int" />
369+
<argument index="0" name="index" type="int" />
369370
<argument index="1" name="checked" type="bool" />
370371
<description>
371-
Sets the checkstate status of the item at index [code]idx[/code].
372+
Sets the checkstate status of the item at the given [code]index[/code].
372373
</description>
373374
</method>
374375
<method name="set_item_disabled">
375376
<return type="void" />
376-
<argument index="0" name="idx" type="int" />
377+
<argument index="0" name="index" type="int" />
377378
<argument index="1" name="disabled" type="bool" />
378379
<description>
379-
Enables/disables the item at index [code]idx[/code]. When it is disabled, it can't be selected and its action can't be invoked.
380+
Enables/disables the item at the given [code]index[/code]. When it is disabled, it can't be selected and its action can't be invoked.
380381
</description>
381382
</method>
382383
<method name="set_item_icon">
383384
<return type="void" />
384-
<argument index="0" name="idx" type="int" />
385+
<argument index="0" name="index" type="int" />
385386
<argument index="1" name="icon" type="Texture2D" />
386387
<description>
387-
Replaces the [Texture2D] icon of the specified [code]idx[/code].
388+
Replaces the [Texture2D] icon of the item at the given [code]index[/code].
388389
</description>
389390
</method>
390391
<method name="set_item_id">
391392
<return type="void" />
392-
<argument index="0" name="idx" type="int" />
393+
<argument index="0" name="index" type="int" />
393394
<argument index="1" name="id" type="int" />
394395
<description>
395-
Sets the [code]id[/code] of the item at index [code]idx[/code].
396+
Sets the [code]id[/code] of the item at the given [code]index[/code].
397+
The [code]id[/code] is used in [signal id_pressed] and [signal id_focused] signals.
396398
</description>
397399
</method>
398400
<method name="set_item_language">
399401
<return type="void" />
400-
<argument index="0" name="idx" type="int" />
402+
<argument index="0" name="index" type="int" />
401403
<argument index="1" name="language" type="String" />
402404
<description>
403405
Sets language code of item's text used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
404406
</description>
405407
</method>
406408
<method name="set_item_metadata">
407409
<return type="void" />
408-
<argument index="0" name="idx" type="int" />
410+
<argument index="0" name="index" type="int" />
409411
<argument index="1" name="metadata" type="Variant" />
410412
<description>
411413
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.
412414
</description>
413415
</method>
414416
<method name="set_item_multistate">
415417
<return type="void" />
416-
<argument index="0" name="idx" type="int" />
418+
<argument index="0" name="index" type="int" />
417419
<argument index="1" name="state" type="int" />
418420
<description>
419421
Sets the state of a multistate item. See [method add_multistate_item] for details.
420422
</description>
421423
</method>
422424
<method name="set_item_opentype_feature">
423425
<return type="void" />
424-
<argument index="0" name="idx" type="int" />
426+
<argument index="0" name="index" type="int" />
425427
<argument index="1" name="tag" type="String" />
426428
<argument index="2" name="value" type="int" />
427429
<description>
@@ -430,63 +432,63 @@
430432
</method>
431433
<method name="set_item_shortcut">
432434
<return type="void" />
433-
<argument index="0" name="idx" type="int" />
435+
<argument index="0" name="index" type="int" />
434436
<argument index="1" name="shortcut" type="Shortcut" />
435437
<argument index="2" name="global" type="bool" default="false" />
436438
<description>
437-
Sets a [Shortcut] for the specified item [code]idx[/code].
439+
Sets a [Shortcut] for the item at the given [code]index[/code].
438440
</description>
439441
</method>
440442
<method name="set_item_shortcut_disabled">
441443
<return type="void" />
442-
<argument index="0" name="idx" type="int" />
444+
<argument index="0" name="index" type="int" />
443445
<argument index="1" name="disabled" type="bool" />
444446
<description>
445-
Disables the [Shortcut] of the specified index [code]idx[/code].
447+
Disables the [Shortcut] of the item at the given [code]index[/code].
446448
</description>
447449
</method>
448450
<method name="set_item_submenu">
449451
<return type="void" />
450-
<argument index="0" name="idx" type="int" />
452+
<argument index="0" name="index" type="int" />
451453
<argument index="1" name="submenu" type="String" />
452454
<description>
453-
Sets the submenu of the item at index [code]idx[/code]. The submenu is the name of a child [PopupMenu] node that would be shown when the item is clicked.
455+
Sets the submenu of the item at the given [code]index[/code]. The submenu is the name of a child [PopupMenu] node that would be shown when the item is clicked.
454456
</description>
455457
</method>
456458
<method name="set_item_text">
457459
<return type="void" />
458-
<argument index="0" name="idx" type="int" />
460+
<argument index="0" name="index" type="int" />
459461
<argument index="1" name="text" type="String" />
460462
<description>
461-
Sets the text of the item at index [code]idx[/code].
463+
Sets the text of the item at the given [code]index[/code].
462464
</description>
463465
</method>
464466
<method name="set_item_text_direction">
465467
<return type="void" />
466-
<argument index="0" name="idx" type="int" />
468+
<argument index="0" name="index" type="int" />
467469
<argument index="1" name="direction" type="int" enum="Control.TextDirection" />
468470
<description>
469471
Sets item's text base writing direction.
470472
</description>
471473
</method>
472474
<method name="set_item_tooltip">
473475
<return type="void" />
474-
<argument index="0" name="idx" type="int" />
476+
<argument index="0" name="index" type="int" />
475477
<argument index="1" name="tooltip" type="String" />
476478
<description>
477-
Sets the [String] tooltip of the item at the specified index [code]idx[/code].
479+
Sets the [String] tooltip of the item at the given [code]index[/code].
478480
</description>
479481
</method>
480482
<method name="toggle_item_checked">
481483
<return type="void" />
482-
<argument index="0" name="idx" type="int" />
484+
<argument index="0" name="index" type="int" />
483485
<description>
484-
Toggles the check state of the item of the specified index [code]idx[/code].
486+
Toggles the check state of the item at the given [code]index[/code].
485487
</description>
486488
</method>
487489
<method name="toggle_item_multistate">
488490
<return type="void" />
489-
<argument index="0" name="idx" type="int" />
491+
<argument index="0" name="index" type="int" />
490492
<description>
491493
Cycle to the next state of a multistate item. See [method add_multistate_item] for details.
492494
</description>

0 commit comments

Comments
 (0)