class_popupmenu.rst 75 KB

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