class_popupmenu.rst 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/PopupMenu.xml.
  6. .. _class_PopupMenu:
  7. PopupMenu
  8. =========
  9. **Inherits:** :ref:`Popup<class_Popup>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. PopupMenu displays a list of options.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **PopupMenu** is a :ref:`Control<class_Control>` that displays a list of options. They are popular in toolbars or context menus.
  15. \ **Incremental search:** Like :ref:`ItemList<class_ItemList>` and :ref:`Tree<class_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 :ref:`ProjectSettings.gui/timers/incremental_search_max_interval_msec<class_ProjectSettings_property_gui/timers/incremental_search_max_interval_msec>`.
  16. \ **Note:** The ID values used for items are limited to 32 bits, not full 64 bits of :ref:`int<class_int>`. This has a range of ``-2^32`` to ``2^32 - 1``, i.e. ``-2147483648`` to ``2147483647``.
  17. .. rst-class:: classref-reftable-group
  18. Properties
  19. ----------
  20. .. table::
  21. :widths: auto
  22. +------------------------------------------+----------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  23. | :ref:`bool<class_bool>` | :ref:`allow_search<class_PopupMenu_property_allow_search>` | ``false`` |
  24. +------------------------------------------+----------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  25. | :ref:`FocusMode<enum_Control_FocusMode>` | focus_mode | ``2`` (overrides :ref:`Control<class_Control_property_focus_mode>`) |
  26. +------------------------------------------+----------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`hide_on_checkable_item_selection<class_PopupMenu_property_hide_on_checkable_item_selection>` | ``true`` |
  28. +------------------------------------------+----------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`hide_on_item_selection<class_PopupMenu_property_hide_on_item_selection>` | ``true`` |
  30. +------------------------------------------+----------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`hide_on_state_item_selection<class_PopupMenu_property_hide_on_state_item_selection>` | ``false`` |
  32. +------------------------------------------+----------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`submenu_popup_delay<class_PopupMenu_property_submenu_popup_delay>` | ``0.3`` |
  34. +------------------------------------------+----------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  35. .. rst-class:: classref-reftable-group
  36. Methods
  37. -------
  38. .. table::
  39. :widths: auto
  40. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`add_check_item<class_PopupMenu_method_add_check_item>` **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  42. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`add_check_shortcut<class_PopupMenu_method_add_check_shortcut>` **(** :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)** |
  44. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`add_icon_check_item<class_PopupMenu_method_add_icon_check_item>` **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  46. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`add_icon_check_shortcut<class_PopupMenu_method_add_icon_check_shortcut>` **(** :ref:`Texture<class_Texture>` texture, :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)** |
  48. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`add_icon_item<class_PopupMenu_method_add_icon_item>` **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  50. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`add_icon_radio_check_item<class_PopupMenu_method_add_icon_radio_check_item>` **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  52. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`add_icon_radio_check_shortcut<class_PopupMenu_method_add_icon_radio_check_shortcut>` **(** :ref:`Texture<class_Texture>` texture, :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)** |
  54. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`add_icon_shortcut<class_PopupMenu_method_add_icon_shortcut>` **(** :ref:`Texture<class_Texture>` texture, :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)** |
  56. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`add_item<class_PopupMenu_method_add_item>` **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  58. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`add_multistate_item<class_PopupMenu_method_add_multistate_item>` **(** :ref:`String<class_String>` label, :ref:`int<class_int>` max_states, :ref:`int<class_int>` default_state=0, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  60. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`add_radio_check_item<class_PopupMenu_method_add_radio_check_item>` **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  62. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`add_radio_check_shortcut<class_PopupMenu_method_add_radio_check_shortcut>` **(** :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)** |
  64. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`add_separator<class_PopupMenu_method_add_separator>` **(** :ref:`String<class_String>` label="", :ref:`int<class_int>` id=-1 **)** |
  66. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`add_shortcut<class_PopupMenu_method_add_shortcut>` **(** :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)** |
  68. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`add_submenu_item<class_PopupMenu_method_add_submenu_item>` **(** :ref:`String<class_String>` label, :ref:`String<class_String>` submenu, :ref:`int<class_int>` id=-1 **)** |
  70. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`clear<class_PopupMenu_method_clear>` **(** **)** |
  72. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`int<class_int>` | :ref:`get_current_index<class_PopupMenu_method_get_current_index>` **(** **)** |const| |
  74. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`int<class_int>` | :ref:`get_item_accelerator<class_PopupMenu_method_get_item_accelerator>` **(** :ref:`int<class_int>` idx **)** |const| |
  76. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`int<class_int>` | :ref:`get_item_count<class_PopupMenu_method_get_item_count>` **(** **)** |const| |
  78. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`Texture<class_Texture>` | :ref:`get_item_icon<class_PopupMenu_method_get_item_icon>` **(** :ref:`int<class_int>` idx **)** |const| |
  80. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`int<class_int>` | :ref:`get_item_id<class_PopupMenu_method_get_item_id>` **(** :ref:`int<class_int>` idx **)** |const| |
  82. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`int<class_int>` | :ref:`get_item_index<class_PopupMenu_method_get_item_index>` **(** :ref:`int<class_int>` id **)** |const| |
  84. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`Variant<class_Variant>` | :ref:`get_item_metadata<class_PopupMenu_method_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** |const| |
  86. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`ShortCut<class_ShortCut>` | :ref:`get_item_shortcut<class_PopupMenu_method_get_item_shortcut>` **(** :ref:`int<class_int>` idx **)** |const| |
  88. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`String<class_String>` | :ref:`get_item_submenu<class_PopupMenu_method_get_item_submenu>` **(** :ref:`int<class_int>` idx **)** |const| |
  90. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`String<class_String>` | :ref:`get_item_text<class_PopupMenu_method_get_item_text>` **(** :ref:`int<class_int>` idx **)** |const| |
  92. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`String<class_String>` | :ref:`get_item_tooltip<class_PopupMenu_method_get_item_tooltip>` **(** :ref:`int<class_int>` idx **)** |const| |
  94. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`bool<class_bool>` | :ref:`is_hide_on_window_lose_focus<class_PopupMenu_method_is_hide_on_window_lose_focus>` **(** **)** |const| |
  96. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`bool<class_bool>` | :ref:`is_item_checkable<class_PopupMenu_method_is_item_checkable>` **(** :ref:`int<class_int>` idx **)** |const| |
  98. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`is_item_checked<class_PopupMenu_method_is_item_checked>` **(** :ref:`int<class_int>` idx **)** |const| |
  100. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_PopupMenu_method_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** |const| |
  102. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`bool<class_bool>` | :ref:`is_item_radio_checkable<class_PopupMenu_method_is_item_radio_checkable>` **(** :ref:`int<class_int>` idx **)** |const| |
  104. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`bool<class_bool>` | :ref:`is_item_separator<class_PopupMenu_method_is_item_separator>` **(** :ref:`int<class_int>` idx **)** |const| |
  106. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`bool<class_bool>` | :ref:`is_item_shortcut_disabled<class_PopupMenu_method_is_item_shortcut_disabled>` **(** :ref:`int<class_int>` idx **)** |const| |
  108. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`remove_item<class_PopupMenu_method_remove_item>` **(** :ref:`int<class_int>` idx **)** |
  110. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | void | :ref:`set_current_index<class_PopupMenu_method_set_current_index>` **(** :ref:`int<class_int>` index **)** |
  112. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`set_hide_on_window_lose_focus<class_PopupMenu_method_set_hide_on_window_lose_focus>` **(** :ref:`bool<class_bool>` enable **)** |
  114. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`set_item_accelerator<class_PopupMenu_method_set_item_accelerator>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` accel **)** |
  116. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`set_item_as_checkable<class_PopupMenu_method_set_item_as_checkable>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)** |
  118. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`set_item_as_radio_checkable<class_PopupMenu_method_set_item_as_radio_checkable>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)** |
  120. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | void | :ref:`set_item_as_separator<class_PopupMenu_method_set_item_as_separator>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)** |
  122. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | void | :ref:`set_item_checked<class_PopupMenu_method_set_item_checked>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` checked **)** |
  124. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`set_item_disabled<class_PopupMenu_method_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  126. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | void | :ref:`set_item_icon<class_PopupMenu_method_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` icon **)** |
  128. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`set_item_id<class_PopupMenu_method_set_item_id>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)** |
  130. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | void | :ref:`set_item_metadata<class_PopupMenu_method_set_item_metadata>` **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)** |
  132. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | void | :ref:`set_item_multistate<class_PopupMenu_method_set_item_multistate>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` state **)** |
  134. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | void | :ref:`set_item_shortcut<class_PopupMenu_method_set_item_shortcut>` **(** :ref:`int<class_int>` idx, :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`bool<class_bool>` global=false **)** |
  136. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | void | :ref:`set_item_shortcut_disabled<class_PopupMenu_method_set_item_shortcut_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  138. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | void | :ref:`set_item_submenu<class_PopupMenu_method_set_item_submenu>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` submenu **)** |
  140. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | void | :ref:`set_item_text<class_PopupMenu_method_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)** |
  142. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | void | :ref:`set_item_tooltip<class_PopupMenu_method_set_item_tooltip>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` tooltip **)** |
  144. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | void | :ref:`toggle_item_checked<class_PopupMenu_method_toggle_item_checked>` **(** :ref:`int<class_int>` idx **)** |
  146. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | void | :ref:`toggle_item_multistate<class_PopupMenu_method_toggle_item_multistate>` **(** :ref:`int<class_int>` idx **)** |
  148. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. .. rst-class:: classref-reftable-group
  150. Theme Properties
  151. ----------------
  152. .. table::
  153. :widths: auto
  154. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  155. | :ref:`Color<class_Color>` | :ref:`font_color<class_PopupMenu_theme_color_font_color>` | ``Color( 0.88, 0.88, 0.88, 1 )`` |
  156. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  157. | :ref:`Color<class_Color>` | :ref:`font_color_accel<class_PopupMenu_theme_color_font_color_accel>` | ``Color( 0.7, 0.7, 0.7, 0.8 )`` |
  158. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  159. | :ref:`Color<class_Color>` | :ref:`font_color_disabled<class_PopupMenu_theme_color_font_color_disabled>` | ``Color( 0.4, 0.4, 0.4, 0.8 )`` |
  160. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  161. | :ref:`Color<class_Color>` | :ref:`font_color_hover<class_PopupMenu_theme_color_font_color_hover>` | ``Color( 0.88, 0.88, 0.88, 1 )`` |
  162. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  163. | :ref:`Color<class_Color>` | :ref:`font_color_separator<class_PopupMenu_theme_color_font_color_separator>` | ``Color( 0.88, 0.88, 0.88, 1 )`` |
  164. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  165. | :ref:`int<class_int>` | :ref:`hseparation<class_PopupMenu_theme_constant_hseparation>` | ``4`` |
  166. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  167. | :ref:`int<class_int>` | :ref:`vseparation<class_PopupMenu_theme_constant_vseparation>` | ``4`` |
  168. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  169. | :ref:`Font<class_Font>` | :ref:`font<class_PopupMenu_theme_font_font>` | |
  170. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  171. | :ref:`Font<class_Font>` | :ref:`font_separator<class_PopupMenu_theme_font_font_separator>` | |
  172. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  173. | :ref:`Texture<class_Texture>` | :ref:`checked<class_PopupMenu_theme_icon_checked>` | |
  174. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  175. | :ref:`Texture<class_Texture>` | :ref:`radio_checked<class_PopupMenu_theme_icon_radio_checked>` | |
  176. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  177. | :ref:`Texture<class_Texture>` | :ref:`radio_unchecked<class_PopupMenu_theme_icon_radio_unchecked>` | |
  178. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  179. | :ref:`Texture<class_Texture>` | :ref:`submenu<class_PopupMenu_theme_icon_submenu>` | |
  180. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  181. | :ref:`Texture<class_Texture>` | :ref:`unchecked<class_PopupMenu_theme_icon_unchecked>` | |
  182. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  183. | :ref:`StyleBox<class_StyleBox>` | :ref:`hover<class_PopupMenu_theme_style_hover>` | |
  184. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  185. | :ref:`StyleBox<class_StyleBox>` | :ref:`labeled_separator_left<class_PopupMenu_theme_style_labeled_separator_left>` | |
  186. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  187. | :ref:`StyleBox<class_StyleBox>` | :ref:`labeled_separator_right<class_PopupMenu_theme_style_labeled_separator_right>` | |
  188. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  189. | :ref:`StyleBox<class_StyleBox>` | :ref:`panel<class_PopupMenu_theme_style_panel>` | |
  190. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  191. | :ref:`StyleBox<class_StyleBox>` | :ref:`panel_disabled<class_PopupMenu_theme_style_panel_disabled>` | |
  192. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  193. | :ref:`StyleBox<class_StyleBox>` | :ref:`separator<class_PopupMenu_theme_style_separator>` | |
  194. +---------------------------------+-------------------------------------------------------------------------------------+----------------------------------+
  195. .. rst-class:: classref-section-separator
  196. ----
  197. .. rst-class:: classref-descriptions-group
  198. Signals
  199. -------
  200. .. _class_PopupMenu_signal_id_focused:
  201. .. rst-class:: classref-signal
  202. **id_focused** **(** :ref:`int<class_int>` id **)**
  203. Emitted when user navigated to an item of some ``id`` using ``ui_up`` or ``ui_down`` action.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_PopupMenu_signal_id_pressed:
  207. .. rst-class:: classref-signal
  208. **id_pressed** **(** :ref:`int<class_int>` id **)**
  209. Emitted when an item of some ``id`` is pressed or its accelerator is activated.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_PopupMenu_signal_index_pressed:
  213. .. rst-class:: classref-signal
  214. **index_pressed** **(** :ref:`int<class_int>` index **)**
  215. Emitted when an item of some ``index`` is pressed or its accelerator is activated.
  216. .. rst-class:: classref-section-separator
  217. ----
  218. .. rst-class:: classref-descriptions-group
  219. Property Descriptions
  220. ---------------------
  221. .. _class_PopupMenu_property_allow_search:
  222. .. rst-class:: classref-property
  223. :ref:`bool<class_bool>` **allow_search** = ``false``
  224. .. rst-class:: classref-property-setget
  225. - void **set_allow_search** **(** :ref:`bool<class_bool>` value **)**
  226. - :ref:`bool<class_bool>` **get_allow_search** **(** **)**
  227. If ``true``, allows navigating **PopupMenu** with letter keys.
  228. .. rst-class:: classref-item-separator
  229. ----
  230. .. _class_PopupMenu_property_hide_on_checkable_item_selection:
  231. .. rst-class:: classref-property
  232. :ref:`bool<class_bool>` **hide_on_checkable_item_selection** = ``true``
  233. .. rst-class:: classref-property-setget
  234. - void **set_hide_on_checkable_item_selection** **(** :ref:`bool<class_bool>` value **)**
  235. - :ref:`bool<class_bool>` **is_hide_on_checkable_item_selection** **(** **)**
  236. If ``true``, hides the **PopupMenu** when a checkbox or radio button is selected.
  237. .. rst-class:: classref-item-separator
  238. ----
  239. .. _class_PopupMenu_property_hide_on_item_selection:
  240. .. rst-class:: classref-property
  241. :ref:`bool<class_bool>` **hide_on_item_selection** = ``true``
  242. .. rst-class:: classref-property-setget
  243. - void **set_hide_on_item_selection** **(** :ref:`bool<class_bool>` value **)**
  244. - :ref:`bool<class_bool>` **is_hide_on_item_selection** **(** **)**
  245. If ``true``, hides the **PopupMenu** when an item is selected.
  246. .. rst-class:: classref-item-separator
  247. ----
  248. .. _class_PopupMenu_property_hide_on_state_item_selection:
  249. .. rst-class:: classref-property
  250. :ref:`bool<class_bool>` **hide_on_state_item_selection** = ``false``
  251. .. rst-class:: classref-property-setget
  252. - void **set_hide_on_state_item_selection** **(** :ref:`bool<class_bool>` value **)**
  253. - :ref:`bool<class_bool>` **is_hide_on_state_item_selection** **(** **)**
  254. If ``true``, hides the **PopupMenu** when a state item is selected.
  255. .. rst-class:: classref-item-separator
  256. ----
  257. .. _class_PopupMenu_property_submenu_popup_delay:
  258. .. rst-class:: classref-property
  259. :ref:`float<class_float>` **submenu_popup_delay** = ``0.3``
  260. .. rst-class:: classref-property-setget
  261. - void **set_submenu_popup_delay** **(** :ref:`float<class_float>` value **)**
  262. - :ref:`float<class_float>` **get_submenu_popup_delay** **(** **)**
  263. 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.
  264. .. rst-class:: classref-section-separator
  265. ----
  266. .. rst-class:: classref-descriptions-group
  267. Method Descriptions
  268. -------------------
  269. .. _class_PopupMenu_method_add_check_item:
  270. .. rst-class:: classref-method
  271. void **add_check_item** **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  272. Adds a new checkable item with text ``label``.
  273. An ``id`` can optionally be provided, as well as an accelerator (``accel``). If no ``id`` is provided, one will be created from the index. If no ``accel`` is provided then the default ``0`` will be assigned to it. See :ref:`get_item_accelerator<class_PopupMenu_method_get_item_accelerator>` for more info on accelerators.
  274. \ **Note:** Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See :ref:`set_item_checked<class_PopupMenu_method_set_item_checked>` for more info on how to control it.
  275. .. rst-class:: classref-item-separator
  276. ----
  277. .. _class_PopupMenu_method_add_check_shortcut:
  278. .. rst-class:: classref-method
  279. void **add_check_shortcut** **(** :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)**
  280. Adds a new checkable item and assigns the specified :ref:`ShortCut<class_ShortCut>` to it. Sets the label of the checkbox to the :ref:`ShortCut<class_ShortCut>`'s name.
  281. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  282. \ **Note:** Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See :ref:`set_item_checked<class_PopupMenu_method_set_item_checked>` for more info on how to control it.
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _class_PopupMenu_method_add_icon_check_item:
  286. .. rst-class:: classref-method
  287. void **add_icon_check_item** **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  288. Adds a new checkable item with text ``label`` and icon ``texture``.
  289. An ``id`` can optionally be provided, as well as an accelerator (``accel``). If no ``id`` is provided, one will be created from the index. If no ``accel`` is provided then the default ``0`` will be assigned to it. See :ref:`get_item_accelerator<class_PopupMenu_method_get_item_accelerator>` for more info on accelerators.
  290. \ **Note:** Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See :ref:`set_item_checked<class_PopupMenu_method_set_item_checked>` for more info on how to control it.
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_PopupMenu_method_add_icon_check_shortcut:
  294. .. rst-class:: classref-method
  295. void **add_icon_check_shortcut** **(** :ref:`Texture<class_Texture>` texture, :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)**
  296. Adds a new checkable item and assigns the specified :ref:`ShortCut<class_ShortCut>` and icon ``texture`` to it. Sets the label of the checkbox to the :ref:`ShortCut<class_ShortCut>`'s name.
  297. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  298. \ **Note:** Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See :ref:`set_item_checked<class_PopupMenu_method_set_item_checked>` for more info on how to control it.
  299. .. rst-class:: classref-item-separator
  300. ----
  301. .. _class_PopupMenu_method_add_icon_item:
  302. .. rst-class:: classref-method
  303. void **add_icon_item** **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  304. Adds a new item with text ``label`` and icon ``texture``.
  305. An ``id`` can optionally be provided, as well as an accelerator (``accel``). If no ``id`` is provided, one will be created from the index. If no ``accel`` is provided then the default ``0`` will be assigned to it. See :ref:`get_item_accelerator<class_PopupMenu_method_get_item_accelerator>` for more info on accelerators.
  306. .. rst-class:: classref-item-separator
  307. ----
  308. .. _class_PopupMenu_method_add_icon_radio_check_item:
  309. .. rst-class:: classref-method
  310. void **add_icon_radio_check_item** **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  311. Same as :ref:`add_icon_check_item<class_PopupMenu_method_add_icon_check_item>`, but uses a radio check button.
  312. .. rst-class:: classref-item-separator
  313. ----
  314. .. _class_PopupMenu_method_add_icon_radio_check_shortcut:
  315. .. rst-class:: classref-method
  316. void **add_icon_radio_check_shortcut** **(** :ref:`Texture<class_Texture>` texture, :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)**
  317. Same as :ref:`add_icon_check_shortcut<class_PopupMenu_method_add_icon_check_shortcut>`, but uses a radio check button.
  318. .. rst-class:: classref-item-separator
  319. ----
  320. .. _class_PopupMenu_method_add_icon_shortcut:
  321. .. rst-class:: classref-method
  322. void **add_icon_shortcut** **(** :ref:`Texture<class_Texture>` texture, :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)**
  323. Adds a new item and assigns the specified :ref:`ShortCut<class_ShortCut>` and icon ``texture`` to it. Sets the label of the checkbox to the :ref:`ShortCut<class_ShortCut>`'s name.
  324. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  325. .. rst-class:: classref-item-separator
  326. ----
  327. .. _class_PopupMenu_method_add_item:
  328. .. rst-class:: classref-method
  329. void **add_item** **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  330. Adds a new item with text ``label``.
  331. An ``id`` can optionally be provided, as well as an accelerator (``accel``). If no ``id`` is provided, one will be created from the index. If no ``accel`` is provided then the default ``0`` will be assigned to it. See :ref:`get_item_accelerator<class_PopupMenu_method_get_item_accelerator>` for more info on accelerators.
  332. .. rst-class:: classref-item-separator
  333. ----
  334. .. _class_PopupMenu_method_add_multistate_item:
  335. .. rst-class:: classref-method
  336. void **add_multistate_item** **(** :ref:`String<class_String>` label, :ref:`int<class_int>` max_states, :ref:`int<class_int>` default_state=0, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  337. Adds a new multistate item with text ``label``.
  338. Contrarily to normal binary items, multistate items can have more than two states, as defined by ``max_states``. Each press or activate of the item will increase the state by one. The default value is defined by ``default_state``.
  339. An ``id`` can optionally be provided, as well as an accelerator (``accel``). If no ``id`` is provided, one will be created from the index. If no ``accel`` is provided then the default ``0`` will be assigned to it. See :ref:`get_item_accelerator<class_PopupMenu_method_get_item_accelerator>` for more info on accelerators.
  340. .. rst-class:: classref-item-separator
  341. ----
  342. .. _class_PopupMenu_method_add_radio_check_item:
  343. .. rst-class:: classref-method
  344. void **add_radio_check_item** **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  345. Adds a new radio check button with text ``label``.
  346. An ``id`` can optionally be provided, as well as an accelerator (``accel``). If no ``id`` is provided, one will be created from the index. If no ``accel`` is provided then the default ``0`` will be assigned to it. See :ref:`get_item_accelerator<class_PopupMenu_method_get_item_accelerator>` for more info on accelerators.
  347. \ **Note:** Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See :ref:`set_item_checked<class_PopupMenu_method_set_item_checked>` for more info on how to control it.
  348. .. rst-class:: classref-item-separator
  349. ----
  350. .. _class_PopupMenu_method_add_radio_check_shortcut:
  351. .. rst-class:: classref-method
  352. void **add_radio_check_shortcut** **(** :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)**
  353. Adds a new radio check button and assigns a :ref:`ShortCut<class_ShortCut>` to it. Sets the label of the checkbox to the :ref:`ShortCut<class_ShortCut>`'s name.
  354. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  355. \ **Note:** Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See :ref:`set_item_checked<class_PopupMenu_method_set_item_checked>` for more info on how to control it.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_PopupMenu_method_add_separator:
  359. .. rst-class:: classref-method
  360. void **add_separator** **(** :ref:`String<class_String>` label="", :ref:`int<class_int>` id=-1 **)**
  361. Adds a separator between items. Separators also occupy an index, which you can set by using the ``id`` parameter.
  362. A ``label`` can optionally be provided, which will appear at the center of the separator.
  363. .. rst-class:: classref-item-separator
  364. ----
  365. .. _class_PopupMenu_method_add_shortcut:
  366. .. rst-class:: classref-method
  367. void **add_shortcut** **(** :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)**
  368. Adds a :ref:`ShortCut<class_ShortCut>`.
  369. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_PopupMenu_method_add_submenu_item:
  373. .. rst-class:: classref-method
  374. void **add_submenu_item** **(** :ref:`String<class_String>` label, :ref:`String<class_String>` submenu, :ref:`int<class_int>` id=-1 **)**
  375. Adds an item that will act as a submenu of the parent **PopupMenu** node when clicked. The ``submenu`` argument is the name of the child **PopupMenu** node that will be shown when the item is clicked.
  376. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  377. .. rst-class:: classref-item-separator
  378. ----
  379. .. _class_PopupMenu_method_clear:
  380. .. rst-class:: classref-method
  381. void **clear** **(** **)**
  382. Removes all items from the **PopupMenu**.
  383. .. rst-class:: classref-item-separator
  384. ----
  385. .. _class_PopupMenu_method_get_current_index:
  386. .. rst-class:: classref-method
  387. :ref:`int<class_int>` **get_current_index** **(** **)** |const|
  388. Returns the index of the currently focused item. Returns ``-1`` if no item is focused.
  389. .. rst-class:: classref-item-separator
  390. ----
  391. .. _class_PopupMenu_method_get_item_accelerator:
  392. .. rst-class:: classref-method
  393. :ref:`int<class_int>` **get_item_accelerator** **(** :ref:`int<class_int>` idx **)** |const|
  394. Returns the accelerator of the item at index ``idx``. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
  395. .. rst-class:: classref-item-separator
  396. ----
  397. .. _class_PopupMenu_method_get_item_count:
  398. .. rst-class:: classref-method
  399. :ref:`int<class_int>` **get_item_count** **(** **)** |const|
  400. Returns the number of items in the **PopupMenu**.
  401. .. rst-class:: classref-item-separator
  402. ----
  403. .. _class_PopupMenu_method_get_item_icon:
  404. .. rst-class:: classref-method
  405. :ref:`Texture<class_Texture>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** |const|
  406. Returns the icon of the item at index ``idx``.
  407. .. rst-class:: classref-item-separator
  408. ----
  409. .. _class_PopupMenu_method_get_item_id:
  410. .. rst-class:: classref-method
  411. :ref:`int<class_int>` **get_item_id** **(** :ref:`int<class_int>` idx **)** |const|
  412. Returns the id of the item at index ``idx``. ``id`` can be manually assigned, while index can not.
  413. .. rst-class:: classref-item-separator
  414. ----
  415. .. _class_PopupMenu_method_get_item_index:
  416. .. rst-class:: classref-method
  417. :ref:`int<class_int>` **get_item_index** **(** :ref:`int<class_int>` id **)** |const|
  418. Returns the index of the item containing the specified ``id``. Index is automatically assigned to each item by the engine. Index can not be set manually.
  419. .. rst-class:: classref-item-separator
  420. ----
  421. .. _class_PopupMenu_method_get_item_metadata:
  422. .. rst-class:: classref-method
  423. :ref:`Variant<class_Variant>` **get_item_metadata** **(** :ref:`int<class_int>` idx **)** |const|
  424. Returns the metadata of the specified item, which might be of any type. You can set it with :ref:`set_item_metadata<class_PopupMenu_method_set_item_metadata>`, which provides a simple way of assigning context data to items.
  425. .. rst-class:: classref-item-separator
  426. ----
  427. .. _class_PopupMenu_method_get_item_shortcut:
  428. .. rst-class:: classref-method
  429. :ref:`ShortCut<class_ShortCut>` **get_item_shortcut** **(** :ref:`int<class_int>` idx **)** |const|
  430. Returns the :ref:`ShortCut<class_ShortCut>` associated with the specified ``idx`` item.
  431. .. rst-class:: classref-item-separator
  432. ----
  433. .. _class_PopupMenu_method_get_item_submenu:
  434. .. rst-class:: classref-method
  435. :ref:`String<class_String>` **get_item_submenu** **(** :ref:`int<class_int>` idx **)** |const|
  436. Returns the submenu name of the item at index ``idx``. See :ref:`add_submenu_item<class_PopupMenu_method_add_submenu_item>` for more info on how to add a submenu.
  437. .. rst-class:: classref-item-separator
  438. ----
  439. .. _class_PopupMenu_method_get_item_text:
  440. .. rst-class:: classref-method
  441. :ref:`String<class_String>` **get_item_text** **(** :ref:`int<class_int>` idx **)** |const|
  442. Returns the text of the item at index ``idx``.
  443. .. rst-class:: classref-item-separator
  444. ----
  445. .. _class_PopupMenu_method_get_item_tooltip:
  446. .. rst-class:: classref-method
  447. :ref:`String<class_String>` **get_item_tooltip** **(** :ref:`int<class_int>` idx **)** |const|
  448. Returns the tooltip associated with the specified index ``idx``.
  449. .. rst-class:: classref-item-separator
  450. ----
  451. .. _class_PopupMenu_method_is_hide_on_window_lose_focus:
  452. .. rst-class:: classref-method
  453. :ref:`bool<class_bool>` **is_hide_on_window_lose_focus** **(** **)** |const|
  454. Returns ``true`` if the popup will be hidden when the window loses focus or not.
  455. .. rst-class:: classref-item-separator
  456. ----
  457. .. _class_PopupMenu_method_is_item_checkable:
  458. .. rst-class:: classref-method
  459. :ref:`bool<class_bool>` **is_item_checkable** **(** :ref:`int<class_int>` idx **)** |const|
  460. Returns ``true`` if the item at index ``idx`` is checkable in some way, i.e. if it has a checkbox or radio button.
  461. \ **Note:** Checkable items just display a checkmark or radio button, but don't have any built-in checking behavior and must be checked/unchecked manually.
  462. .. rst-class:: classref-item-separator
  463. ----
  464. .. _class_PopupMenu_method_is_item_checked:
  465. .. rst-class:: classref-method
  466. :ref:`bool<class_bool>` **is_item_checked** **(** :ref:`int<class_int>` idx **)** |const|
  467. Returns ``true`` if the item at index ``idx`` is checked.
  468. .. rst-class:: classref-item-separator
  469. ----
  470. .. _class_PopupMenu_method_is_item_disabled:
  471. .. rst-class:: classref-method
  472. :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** |const|
  473. Returns ``true`` if the item at index ``idx`` is disabled. When it is disabled it can't be selected, or its action invoked.
  474. See :ref:`set_item_disabled<class_PopupMenu_method_set_item_disabled>` for more info on how to disable an item.
  475. .. rst-class:: classref-item-separator
  476. ----
  477. .. _class_PopupMenu_method_is_item_radio_checkable:
  478. .. rst-class:: classref-method
  479. :ref:`bool<class_bool>` **is_item_radio_checkable** **(** :ref:`int<class_int>` idx **)** |const|
  480. Returns ``true`` if the item at index ``idx`` has radio button-style checkability.
  481. \ **Note:** This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
  482. .. rst-class:: classref-item-separator
  483. ----
  484. .. _class_PopupMenu_method_is_item_separator:
  485. .. rst-class:: classref-method
  486. :ref:`bool<class_bool>` **is_item_separator** **(** :ref:`int<class_int>` idx **)** |const|
  487. Returns ``true`` if the item is a separator. If it is, it will be displayed as a line. See :ref:`add_separator<class_PopupMenu_method_add_separator>` for more info on how to add a separator.
  488. .. rst-class:: classref-item-separator
  489. ----
  490. .. _class_PopupMenu_method_is_item_shortcut_disabled:
  491. .. rst-class:: classref-method
  492. :ref:`bool<class_bool>` **is_item_shortcut_disabled** **(** :ref:`int<class_int>` idx **)** |const|
  493. Returns ``true`` if the specified item's shortcut is disabled.
  494. .. rst-class:: classref-item-separator
  495. ----
  496. .. _class_PopupMenu_method_remove_item:
  497. .. rst-class:: classref-method
  498. void **remove_item** **(** :ref:`int<class_int>` idx **)**
  499. Removes the item at index ``idx`` from the menu.
  500. \ **Note:** The indices of items after the removed item will be shifted by one.
  501. .. rst-class:: classref-item-separator
  502. ----
  503. .. _class_PopupMenu_method_set_current_index:
  504. .. rst-class:: classref-method
  505. void **set_current_index** **(** :ref:`int<class_int>` index **)**
  506. Sets the currently focused item as the given ``index``.
  507. Passing ``-1`` as the index makes so that no item is focused.
  508. .. rst-class:: classref-item-separator
  509. ----
  510. .. _class_PopupMenu_method_set_hide_on_window_lose_focus:
  511. .. rst-class:: classref-method
  512. void **set_hide_on_window_lose_focus** **(** :ref:`bool<class_bool>` enable **)**
  513. Hides the **PopupMenu** when the window loses focus.
  514. .. rst-class:: classref-item-separator
  515. ----
  516. .. _class_PopupMenu_method_set_item_accelerator:
  517. .. rst-class:: classref-method
  518. void **set_item_accelerator** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` accel **)**
  519. Sets the accelerator of the item at index ``idx``. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
  520. .. rst-class:: classref-item-separator
  521. ----
  522. .. _class_PopupMenu_method_set_item_as_checkable:
  523. .. rst-class:: classref-method
  524. void **set_item_as_checkable** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  525. Sets whether the item at index ``idx`` has a checkbox. If ``false``, sets the type of the item to plain text.
  526. \ **Note:** Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
  527. .. rst-class:: classref-item-separator
  528. ----
  529. .. _class_PopupMenu_method_set_item_as_radio_checkable:
  530. .. rst-class:: classref-method
  531. void **set_item_as_radio_checkable** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  532. Sets the type of the item at the specified index ``idx`` to radio button. If ``false``, sets the type of the item to plain text.
  533. .. rst-class:: classref-item-separator
  534. ----
  535. .. _class_PopupMenu_method_set_item_as_separator:
  536. .. rst-class:: classref-method
  537. void **set_item_as_separator** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  538. Mark the item at index ``idx`` as a separator, which means that it would be displayed as a line. If ``false``, sets the type of the item to plain text.
  539. .. rst-class:: classref-item-separator
  540. ----
  541. .. _class_PopupMenu_method_set_item_checked:
  542. .. rst-class:: classref-method
  543. void **set_item_checked** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` checked **)**
  544. Sets the checkstate status of the item at index ``idx``.
  545. .. rst-class:: classref-item-separator
  546. ----
  547. .. _class_PopupMenu_method_set_item_disabled:
  548. .. rst-class:: classref-method
  549. void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  550. Enables/disables the item at index ``idx``. When it is disabled, it can't be selected and its action can't be invoked.
  551. .. rst-class:: classref-item-separator
  552. ----
  553. .. _class_PopupMenu_method_set_item_icon:
  554. .. rst-class:: classref-method
  555. void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` icon **)**
  556. Replaces the :ref:`Texture<class_Texture>` icon of the specified ``idx``.
  557. .. rst-class:: classref-item-separator
  558. ----
  559. .. _class_PopupMenu_method_set_item_id:
  560. .. rst-class:: classref-method
  561. void **set_item_id** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)**
  562. Sets the ``id`` of the item at index ``idx``.
  563. .. rst-class:: classref-item-separator
  564. ----
  565. .. _class_PopupMenu_method_set_item_metadata:
  566. .. rst-class:: classref-method
  567. void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)**
  568. Sets the metadata of an item, which may be of any type. You can later get it with :ref:`get_item_metadata<class_PopupMenu_method_get_item_metadata>`, which provides a simple way of assigning context data to items.
  569. .. rst-class:: classref-item-separator
  570. ----
  571. .. _class_PopupMenu_method_set_item_multistate:
  572. .. rst-class:: classref-method
  573. void **set_item_multistate** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` state **)**
  574. Sets the state of a multistate item. See :ref:`add_multistate_item<class_PopupMenu_method_add_multistate_item>` for details.
  575. .. rst-class:: classref-item-separator
  576. ----
  577. .. _class_PopupMenu_method_set_item_shortcut:
  578. .. rst-class:: classref-method
  579. void **set_item_shortcut** **(** :ref:`int<class_int>` idx, :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`bool<class_bool>` global=false **)**
  580. Sets a :ref:`ShortCut<class_ShortCut>` for the specified item ``idx``.
  581. .. rst-class:: classref-item-separator
  582. ----
  583. .. _class_PopupMenu_method_set_item_shortcut_disabled:
  584. .. rst-class:: classref-method
  585. void **set_item_shortcut_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  586. Disables the :ref:`ShortCut<class_ShortCut>` of the specified index ``idx``.
  587. .. rst-class:: classref-item-separator
  588. ----
  589. .. _class_PopupMenu_method_set_item_submenu:
  590. .. rst-class:: classref-method
  591. void **set_item_submenu** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` submenu **)**
  592. Sets the submenu of the item at index ``idx``. The submenu is the name of a child **PopupMenu** node that would be shown when the item is clicked.
  593. .. rst-class:: classref-item-separator
  594. ----
  595. .. _class_PopupMenu_method_set_item_text:
  596. .. rst-class:: classref-method
  597. void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)**
  598. Sets the text of the item at index ``idx``.
  599. .. rst-class:: classref-item-separator
  600. ----
  601. .. _class_PopupMenu_method_set_item_tooltip:
  602. .. rst-class:: classref-method
  603. void **set_item_tooltip** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` tooltip **)**
  604. Sets the :ref:`String<class_String>` tooltip of the item at the specified index ``idx``.
  605. .. rst-class:: classref-item-separator
  606. ----
  607. .. _class_PopupMenu_method_toggle_item_checked:
  608. .. rst-class:: classref-method
  609. void **toggle_item_checked** **(** :ref:`int<class_int>` idx **)**
  610. Toggles the check state of the item of the specified index ``idx``.
  611. .. rst-class:: classref-item-separator
  612. ----
  613. .. _class_PopupMenu_method_toggle_item_multistate:
  614. .. rst-class:: classref-method
  615. void **toggle_item_multistate** **(** :ref:`int<class_int>` idx **)**
  616. Cycle to the next state of a multistate item. See :ref:`add_multistate_item<class_PopupMenu_method_add_multistate_item>` for details.
  617. .. rst-class:: classref-section-separator
  618. ----
  619. .. rst-class:: classref-descriptions-group
  620. Theme Property Descriptions
  621. ---------------------------
  622. .. _class_PopupMenu_theme_color_font_color:
  623. .. rst-class:: classref-themeproperty
  624. :ref:`Color<class_Color>` **font_color** = ``Color( 0.88, 0.88, 0.88, 1 )``
  625. The default text :ref:`Color<class_Color>` for menu items' names.
  626. .. rst-class:: classref-item-separator
  627. ----
  628. .. _class_PopupMenu_theme_color_font_color_accel:
  629. .. rst-class:: classref-themeproperty
  630. :ref:`Color<class_Color>` **font_color_accel** = ``Color( 0.7, 0.7, 0.7, 0.8 )``
  631. The text :ref:`Color<class_Color>` used for shortcuts and accelerators that show next to the menu item name when defined. See :ref:`get_item_accelerator<class_PopupMenu_method_get_item_accelerator>` for more info on accelerators.
  632. .. rst-class:: classref-item-separator
  633. ----
  634. .. _class_PopupMenu_theme_color_font_color_disabled:
  635. .. rst-class:: classref-themeproperty
  636. :ref:`Color<class_Color>` **font_color_disabled** = ``Color( 0.4, 0.4, 0.4, 0.8 )``
  637. :ref:`Color<class_Color>` used for disabled menu items' text.
  638. .. rst-class:: classref-item-separator
  639. ----
  640. .. _class_PopupMenu_theme_color_font_color_hover:
  641. .. rst-class:: classref-themeproperty
  642. :ref:`Color<class_Color>` **font_color_hover** = ``Color( 0.88, 0.88, 0.88, 1 )``
  643. :ref:`Color<class_Color>` used for the hovered text.
  644. .. rst-class:: classref-item-separator
  645. ----
  646. .. _class_PopupMenu_theme_color_font_color_separator:
  647. .. rst-class:: classref-themeproperty
  648. :ref:`Color<class_Color>` **font_color_separator** = ``Color( 0.88, 0.88, 0.88, 1 )``
  649. :ref:`Color<class_Color>` used for labeled separators' text. See :ref:`add_separator<class_PopupMenu_method_add_separator>`.
  650. .. rst-class:: classref-item-separator
  651. ----
  652. .. _class_PopupMenu_theme_constant_hseparation:
  653. .. rst-class:: classref-themeproperty
  654. :ref:`int<class_int>` **hseparation** = ``4``
  655. The horizontal space between the item's name and the shortcut text/submenu arrow.
  656. .. rst-class:: classref-item-separator
  657. ----
  658. .. _class_PopupMenu_theme_constant_vseparation:
  659. .. rst-class:: classref-themeproperty
  660. :ref:`int<class_int>` **vseparation** = ``4``
  661. The vertical space between each menu item.
  662. .. rst-class:: classref-item-separator
  663. ----
  664. .. _class_PopupMenu_theme_font_font:
  665. .. rst-class:: classref-themeproperty
  666. :ref:`Font<class_Font>` **font**
  667. :ref:`Font<class_Font>` used for the menu items.
  668. .. rst-class:: classref-item-separator
  669. ----
  670. .. _class_PopupMenu_theme_font_font_separator:
  671. .. rst-class:: classref-themeproperty
  672. :ref:`Font<class_Font>` **font_separator**
  673. :ref:`Font<class_Font>` used for the labeled separator.
  674. .. rst-class:: classref-item-separator
  675. ----
  676. .. _class_PopupMenu_theme_icon_checked:
  677. .. rst-class:: classref-themeproperty
  678. :ref:`Texture<class_Texture>` **checked**
  679. :ref:`Texture<class_Texture>` icon for the checked checkbox items.
  680. .. rst-class:: classref-item-separator
  681. ----
  682. .. _class_PopupMenu_theme_icon_radio_checked:
  683. .. rst-class:: classref-themeproperty
  684. :ref:`Texture<class_Texture>` **radio_checked**
  685. :ref:`Texture<class_Texture>` icon for the checked radio button items.
  686. .. rst-class:: classref-item-separator
  687. ----
  688. .. _class_PopupMenu_theme_icon_radio_unchecked:
  689. .. rst-class:: classref-themeproperty
  690. :ref:`Texture<class_Texture>` **radio_unchecked**
  691. :ref:`Texture<class_Texture>` icon for the unchecked radio button items.
  692. .. rst-class:: classref-item-separator
  693. ----
  694. .. _class_PopupMenu_theme_icon_submenu:
  695. .. rst-class:: classref-themeproperty
  696. :ref:`Texture<class_Texture>` **submenu**
  697. :ref:`Texture<class_Texture>` icon for the submenu arrow.
  698. .. rst-class:: classref-item-separator
  699. ----
  700. .. _class_PopupMenu_theme_icon_unchecked:
  701. .. rst-class:: classref-themeproperty
  702. :ref:`Texture<class_Texture>` **unchecked**
  703. :ref:`Texture<class_Texture>` icon for the unchecked checkbox items.
  704. .. rst-class:: classref-item-separator
  705. ----
  706. .. _class_PopupMenu_theme_style_hover:
  707. .. rst-class:: classref-themeproperty
  708. :ref:`StyleBox<class_StyleBox>` **hover**
  709. :ref:`StyleBox<class_StyleBox>` displayed when the **PopupMenu** item is hovered.
  710. .. rst-class:: classref-item-separator
  711. ----
  712. .. _class_PopupMenu_theme_style_labeled_separator_left:
  713. .. rst-class:: classref-themeproperty
  714. :ref:`StyleBox<class_StyleBox>` **labeled_separator_left**
  715. :ref:`StyleBox<class_StyleBox>` for the left side of labeled separator. See :ref:`add_separator<class_PopupMenu_method_add_separator>`.
  716. .. rst-class:: classref-item-separator
  717. ----
  718. .. _class_PopupMenu_theme_style_labeled_separator_right:
  719. .. rst-class:: classref-themeproperty
  720. :ref:`StyleBox<class_StyleBox>` **labeled_separator_right**
  721. :ref:`StyleBox<class_StyleBox>` for the right side of labeled separator. See :ref:`add_separator<class_PopupMenu_method_add_separator>`.
  722. .. rst-class:: classref-item-separator
  723. ----
  724. .. _class_PopupMenu_theme_style_panel:
  725. .. rst-class:: classref-themeproperty
  726. :ref:`StyleBox<class_StyleBox>` **panel**
  727. Default :ref:`StyleBox<class_StyleBox>` of the **PopupMenu** items.
  728. .. rst-class:: classref-item-separator
  729. ----
  730. .. _class_PopupMenu_theme_style_panel_disabled:
  731. .. rst-class:: classref-themeproperty
  732. :ref:`StyleBox<class_StyleBox>` **panel_disabled**
  733. :ref:`StyleBox<class_StyleBox>` used when the **PopupMenu** item is disabled.
  734. .. rst-class:: classref-item-separator
  735. ----
  736. .. _class_PopupMenu_theme_style_separator:
  737. .. rst-class:: classref-themeproperty
  738. :ref:`StyleBox<class_StyleBox>` **separator**
  739. :ref:`StyleBox<class_StyleBox>` used for the separators. See :ref:`add_separator<class_PopupMenu_method_add_separator>`.
  740. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  741. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  742. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  743. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`