class_popupmenu.rst 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the PopupMenu.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_PopupMenu:
  6. PopupMenu
  7. =========
  8. **Inherits:** :ref:`Popup<class_Popup>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. PopupMenu displays a list of options.
  13. Properties
  14. ----------
  15. +---------------------------+----------------------------------------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`hide_on_checkable_item_selection<class_PopupMenu_property_hide_on_checkable_item_selection>` |
  17. +---------------------------+----------------------------------------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`hide_on_item_selection<class_PopupMenu_property_hide_on_item_selection>` |
  19. +---------------------------+----------------------------------------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`hide_on_state_item_selection<class_PopupMenu_property_hide_on_state_item_selection>` |
  21. +---------------------------+----------------------------------------------------------------------------------------------------+
  22. | :ref:`float<class_float>` | :ref:`submenu_popup_delay<class_PopupMenu_property_submenu_popup_delay>` |
  23. +---------------------------+----------------------------------------------------------------------------------------------------+
  24. Methods
  25. -------
  26. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | 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 **)** |
  28. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | 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 **)** |
  30. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | 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 **)** |
  32. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | 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 **)** |
  34. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | 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 **)** |
  36. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | 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 **)** |
  38. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | 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 **)** |
  40. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | 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 **)** |
  42. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | 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 **)** |
  44. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`add_separator<class_PopupMenu_method_add_separator>` **(** :ref:`String<class_String>` label="" **)** |
  46. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | 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 **)** |
  48. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | 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 **)** |
  50. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`clear<class_PopupMenu_method_clear>` **(** **)** |
  52. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`get_item_accelerator<class_PopupMenu_method_get_item_accelerator>` **(** :ref:`int<class_int>` idx **)** const |
  54. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`get_item_count<class_PopupMenu_method_get_item_count>` **(** **)** const |
  56. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Texture<class_Texture>` | :ref:`get_item_icon<class_PopupMenu_method_get_item_icon>` **(** :ref:`int<class_int>` idx **)** const |
  58. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`int<class_int>` | :ref:`get_item_id<class_PopupMenu_method_get_item_id>` **(** :ref:`int<class_int>` idx **)** const |
  60. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`get_item_index<class_PopupMenu_method_get_item_index>` **(** :ref:`int<class_int>` id **)** const |
  62. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Variant<class_Variant>` | :ref:`get_item_metadata<class_PopupMenu_method_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** const |
  64. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`ShortCut<class_ShortCut>` | :ref:`get_item_shortcut<class_PopupMenu_method_get_item_shortcut>` **(** :ref:`int<class_int>` idx **)** const |
  66. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`String<class_String>` | :ref:`get_item_submenu<class_PopupMenu_method_get_item_submenu>` **(** :ref:`int<class_int>` idx **)** const |
  68. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`String<class_String>` | :ref:`get_item_text<class_PopupMenu_method_get_item_text>` **(** :ref:`int<class_int>` idx **)** const |
  70. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`String<class_String>` | :ref:`get_item_tooltip<class_PopupMenu_method_get_item_tooltip>` **(** :ref:`int<class_int>` idx **)** const |
  72. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`is_hide_on_window_lose_focus<class_PopupMenu_method_is_hide_on_window_lose_focus>` **(** **)** const |
  74. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`is_item_checkable<class_PopupMenu_method_is_item_checkable>` **(** :ref:`int<class_int>` idx **)** const |
  76. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`bool<class_bool>` | :ref:`is_item_checked<class_PopupMenu_method_is_item_checked>` **(** :ref:`int<class_int>` idx **)** const |
  78. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_PopupMenu_method_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** const |
  80. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`bool<class_bool>` | :ref:`is_item_radio_checkable<class_PopupMenu_method_is_item_radio_checkable>` **(** :ref:`int<class_int>` idx **)** const |
  82. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`bool<class_bool>` | :ref:`is_item_separator<class_PopupMenu_method_is_item_separator>` **(** :ref:`int<class_int>` idx **)** const |
  84. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`bool<class_bool>` | :ref:`is_item_shortcut_disabled<class_PopupMenu_method_is_item_shortcut_disabled>` **(** :ref:`int<class_int>` idx **)** const |
  86. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`remove_item<class_PopupMenu_method_remove_item>` **(** :ref:`int<class_int>` idx **)** |
  88. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`set_hide_on_window_lose_focus<class_PopupMenu_method_set_hide_on_window_lose_focus>` **(** :ref:`bool<class_bool>` enable **)** |
  90. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`set_item_accelerator<class_PopupMenu_method_set_item_accelerator>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` accel **)** |
  92. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`set_item_as_checkable<class_PopupMenu_method_set_item_as_checkable>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)** |
  94. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | 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 **)** |
  96. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`set_item_as_separator<class_PopupMenu_method_set_item_as_separator>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)** |
  98. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`set_item_checked<class_PopupMenu_method_set_item_checked>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` checked **)** |
  100. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`set_item_disabled<class_PopupMenu_method_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  102. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`set_item_icon<class_PopupMenu_method_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` icon **)** |
  104. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`set_item_id<class_PopupMenu_method_set_item_id>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)** |
  106. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`set_item_metadata<class_PopupMenu_method_set_item_metadata>` **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)** |
  108. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`set_item_multistate<class_PopupMenu_method_set_item_multistate>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` state **)** |
  110. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | 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 **)** |
  112. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`set_item_shortcut_disabled<class_PopupMenu_method_set_item_shortcut_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  114. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`set_item_submenu<class_PopupMenu_method_set_item_submenu>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` submenu **)** |
  116. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`set_item_text<class_PopupMenu_method_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)** |
  118. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`set_item_tooltip<class_PopupMenu_method_set_item_tooltip>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` tooltip **)** |
  120. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | void | :ref:`toggle_item_checked<class_PopupMenu_method_toggle_item_checked>` **(** :ref:`int<class_int>` idx **)** |
  122. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | void | :ref:`toggle_item_multistate<class_PopupMenu_method_toggle_item_multistate>` **(** :ref:`int<class_int>` idx **)** |
  124. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. Theme Properties
  126. ----------------
  127. +---------------------------------+-------------------------+
  128. | :ref:`Texture<class_Texture>` | checked |
  129. +---------------------------------+-------------------------+
  130. | :ref:`Font<class_Font>` | font |
  131. +---------------------------------+-------------------------+
  132. | :ref:`Color<class_Color>` | font_color |
  133. +---------------------------------+-------------------------+
  134. | :ref:`Color<class_Color>` | font_color_accel |
  135. +---------------------------------+-------------------------+
  136. | :ref:`Color<class_Color>` | font_color_disabled |
  137. +---------------------------------+-------------------------+
  138. | :ref:`Color<class_Color>` | font_color_hover |
  139. +---------------------------------+-------------------------+
  140. | :ref:`StyleBox<class_StyleBox>` | hover |
  141. +---------------------------------+-------------------------+
  142. | :ref:`int<class_int>` | hseparation |
  143. +---------------------------------+-------------------------+
  144. | :ref:`StyleBox<class_StyleBox>` | labeled_separator_left |
  145. +---------------------------------+-------------------------+
  146. | :ref:`StyleBox<class_StyleBox>` | labeled_separator_right |
  147. +---------------------------------+-------------------------+
  148. | :ref:`StyleBox<class_StyleBox>` | panel |
  149. +---------------------------------+-------------------------+
  150. | :ref:`StyleBox<class_StyleBox>` | panel_disabled |
  151. +---------------------------------+-------------------------+
  152. | :ref:`Texture<class_Texture>` | radio_checked |
  153. +---------------------------------+-------------------------+
  154. | :ref:`Texture<class_Texture>` | radio_unchecked |
  155. +---------------------------------+-------------------------+
  156. | :ref:`StyleBox<class_StyleBox>` | separator |
  157. +---------------------------------+-------------------------+
  158. | :ref:`Texture<class_Texture>` | submenu |
  159. +---------------------------------+-------------------------+
  160. | :ref:`Texture<class_Texture>` | unchecked |
  161. +---------------------------------+-------------------------+
  162. | :ref:`int<class_int>` | vseparation |
  163. +---------------------------------+-------------------------+
  164. Signals
  165. -------
  166. .. _class_PopupMenu_signal_id_focused:
  167. - **id_focused** **(** :ref:`int<class_int>` ID **)**
  168. This event is emitted when user navigated to an item of some id using ``ui_up`` or ``ui_down`` action.
  169. ----
  170. .. _class_PopupMenu_signal_id_pressed:
  171. - **id_pressed** **(** :ref:`int<class_int>` ID **)**
  172. This event is emitted when an item of some id is pressed or its accelerator is activated.
  173. ----
  174. .. _class_PopupMenu_signal_index_pressed:
  175. - **index_pressed** **(** :ref:`int<class_int>` index **)**
  176. This event is emitted when an item of some index is pressed or its accelerator is activated.
  177. Description
  178. -----------
  179. :ref:`PopupMenu<class_PopupMenu>` is a :ref:`Control<class_Control>` that displays a list of options. They are popular in toolbars or context menus.
  180. Property Descriptions
  181. ---------------------
  182. .. _class_PopupMenu_property_hide_on_checkable_item_selection:
  183. - :ref:`bool<class_bool>` **hide_on_checkable_item_selection**
  184. +----------+---------------------------------------------+
  185. | *Setter* | set_hide_on_checkable_item_selection(value) |
  186. +----------+---------------------------------------------+
  187. | *Getter* | is_hide_on_checkable_item_selection() |
  188. +----------+---------------------------------------------+
  189. If ``true``, hides the :ref:`PopupMenu<class_PopupMenu>` when a checkbox or radio button is selected.
  190. ----
  191. .. _class_PopupMenu_property_hide_on_item_selection:
  192. - :ref:`bool<class_bool>` **hide_on_item_selection**
  193. +----------+-----------------------------------+
  194. | *Setter* | set_hide_on_item_selection(value) |
  195. +----------+-----------------------------------+
  196. | *Getter* | is_hide_on_item_selection() |
  197. +----------+-----------------------------------+
  198. If ``true``, hides the :ref:`PopupMenu<class_PopupMenu>` when an item is selected.
  199. ----
  200. .. _class_PopupMenu_property_hide_on_state_item_selection:
  201. - :ref:`bool<class_bool>` **hide_on_state_item_selection**
  202. +----------+-----------------------------------------+
  203. | *Setter* | set_hide_on_state_item_selection(value) |
  204. +----------+-----------------------------------------+
  205. | *Getter* | is_hide_on_state_item_selection() |
  206. +----------+-----------------------------------------+
  207. If ``true``, hides the :ref:`PopupMenu<class_PopupMenu>` when a state item is selected.
  208. ----
  209. .. _class_PopupMenu_property_submenu_popup_delay:
  210. - :ref:`float<class_float>` **submenu_popup_delay**
  211. +----------+--------------------------------+
  212. | *Setter* | set_submenu_popup_delay(value) |
  213. +----------+--------------------------------+
  214. | *Getter* | get_submenu_popup_delay() |
  215. +----------+--------------------------------+
  216. Sets the delay time 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. Default value: ``0.3`` seconds.
  217. Method Descriptions
  218. -------------------
  219. .. _class_PopupMenu_method_add_check_item:
  220. - void **add_check_item** **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  221. Adds a new checkable item with text ``label``.
  222. 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.
  223. **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.
  224. ----
  225. .. _class_PopupMenu_method_add_check_shortcut:
  226. - void **add_check_shortcut** **(** :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)**
  227. 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.
  228. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  229. **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.
  230. ----
  231. .. _class_PopupMenu_method_add_icon_check_item:
  232. - 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 **)**
  233. Adds a new checkable item with text ``label`` and icon ``texture``.
  234. 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.
  235. **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.
  236. ----
  237. .. _class_PopupMenu_method_add_icon_check_shortcut:
  238. - 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 **)**
  239. 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.
  240. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  241. **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.
  242. ----
  243. .. _class_PopupMenu_method_add_icon_item:
  244. - 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 **)**
  245. Adds a new item with text ``label`` and icon ``texture``.
  246. 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.
  247. ----
  248. .. _class_PopupMenu_method_add_icon_shortcut:
  249. - 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 **)**
  250. 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.
  251. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  252. ----
  253. .. _class_PopupMenu_method_add_item:
  254. - void **add_item** **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  255. Adds a new item with text ``label``.
  256. 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.
  257. ----
  258. .. _class_PopupMenu_method_add_radio_check_item:
  259. - void **add_radio_check_item** **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  260. Adds a new radio button with text ``label``.
  261. 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.
  262. **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.
  263. ----
  264. .. _class_PopupMenu_method_add_radio_check_shortcut:
  265. - void **add_radio_check_shortcut** **(** :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)**
  266. 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.
  267. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  268. **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.
  269. ----
  270. .. _class_PopupMenu_method_add_separator:
  271. - void **add_separator** **(** :ref:`String<class_String>` label="" **)**
  272. Add a separator between items. Separators also occupy an index.
  273. ----
  274. .. _class_PopupMenu_method_add_shortcut:
  275. - void **add_shortcut** **(** :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`int<class_int>` id=-1, :ref:`bool<class_bool>` global=false **)**
  276. Adds a :ref:`ShortCut<class_ShortCut>`.
  277. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  278. ----
  279. .. _class_PopupMenu_method_add_submenu_item:
  280. - void **add_submenu_item** **(** :ref:`String<class_String>` label, :ref:`String<class_String>` submenu, :ref:`int<class_int>` id=-1 **)**
  281. Adds an item that will act as a submenu of the parent :ref:`PopupMenu<class_PopupMenu>` node when clicked. The ``submenu`` argument is the name of the child :ref:`PopupMenu<class_PopupMenu>` node that will be shown when the item is clicked.
  282. An ``id`` can optionally be provided. If no ``id`` is provided, one will be created from the index.
  283. ----
  284. .. _class_PopupMenu_method_clear:
  285. - void **clear** **(** **)**
  286. Removes all items from the :ref:`PopupMenu<class_PopupMenu>`.
  287. ----
  288. .. _class_PopupMenu_method_get_item_accelerator:
  289. - :ref:`int<class_int>` **get_item_accelerator** **(** :ref:`int<class_int>` idx **)** const
  290. 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.
  291. ----
  292. .. _class_PopupMenu_method_get_item_count:
  293. - :ref:`int<class_int>` **get_item_count** **(** **)** const
  294. Returns the number of items in the :ref:`PopupMenu<class_PopupMenu>`.
  295. ----
  296. .. _class_PopupMenu_method_get_item_icon:
  297. - :ref:`Texture<class_Texture>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** const
  298. Returns the icon of the item at index "idx".
  299. ----
  300. .. _class_PopupMenu_method_get_item_id:
  301. - :ref:`int<class_int>` **get_item_id** **(** :ref:`int<class_int>` idx **)** const
  302. Returns the id of the item at index ``idx``. ``id`` can be manually assigned, while index can not.
  303. ----
  304. .. _class_PopupMenu_method_get_item_index:
  305. - :ref:`int<class_int>` **get_item_index** **(** :ref:`int<class_int>` id **)** const
  306. 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 manualy.
  307. ----
  308. .. _class_PopupMenu_method_get_item_metadata:
  309. - :ref:`Variant<class_Variant>` **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
  310. 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.
  311. ----
  312. .. _class_PopupMenu_method_get_item_shortcut:
  313. - :ref:`ShortCut<class_ShortCut>` **get_item_shortcut** **(** :ref:`int<class_int>` idx **)** const
  314. Returns the :ref:`ShortCut<class_ShortCut>` associated with the specified ``idx`` item.
  315. ----
  316. .. _class_PopupMenu_method_get_item_submenu:
  317. - :ref:`String<class_String>` **get_item_submenu** **(** :ref:`int<class_int>` idx **)** const
  318. 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.
  319. ----
  320. .. _class_PopupMenu_method_get_item_text:
  321. - :ref:`String<class_String>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
  322. Returns the text of the item at index "idx".
  323. ----
  324. .. _class_PopupMenu_method_get_item_tooltip:
  325. - :ref:`String<class_String>` **get_item_tooltip** **(** :ref:`int<class_int>` idx **)** const
  326. Returns the tooltip associated with the specified index index ``idx``.
  327. ----
  328. .. _class_PopupMenu_method_is_hide_on_window_lose_focus:
  329. - :ref:`bool<class_bool>` **is_hide_on_window_lose_focus** **(** **)** const
  330. Returns whether the popup will be hidden when the window loses focus or not.
  331. ----
  332. .. _class_PopupMenu_method_is_item_checkable:
  333. - :ref:`bool<class_bool>` **is_item_checkable** **(** :ref:`int<class_int>` idx **)** const
  334. Returns whether the item at index "idx" is checkable in some way, i.e., whether has a checkbox or radio button. Note that checkable items just display a checkmark or radio button, but don't have any built-in checking behavior and must be checked/unchecked manually.
  335. ----
  336. .. _class_PopupMenu_method_is_item_checked:
  337. - :ref:`bool<class_bool>` **is_item_checked** **(** :ref:`int<class_int>` idx **)** const
  338. Returns whether the item at index "idx" is checked.
  339. ----
  340. .. _class_PopupMenu_method_is_item_disabled:
  341. - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
  342. Returns ``true`` if the item at index ``idx`` is disabled. When it is disabled it can't be selected, or its action invoked.
  343. See :ref:`set_item_disabled<class_PopupMenu_method_set_item_disabled>` for more info on how to disable an item.
  344. ----
  345. .. _class_PopupMenu_method_is_item_radio_checkable:
  346. - :ref:`bool<class_bool>` **is_item_radio_checkable** **(** :ref:`int<class_int>` idx **)** const
  347. Returns ``true`` if the item at index ``idx`` has radio button-style checkability.
  348. **Note:** This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
  349. ----
  350. .. _class_PopupMenu_method_is_item_separator:
  351. - :ref:`bool<class_bool>` **is_item_separator** **(** :ref:`int<class_int>` idx **)** const
  352. 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.
  353. ----
  354. .. _class_PopupMenu_method_is_item_shortcut_disabled:
  355. - :ref:`bool<class_bool>` **is_item_shortcut_disabled** **(** :ref:`int<class_int>` idx **)** const
  356. Returns whether the shortcut of the specified item ``idx`` is disabled or not.
  357. ----
  358. .. _class_PopupMenu_method_remove_item:
  359. - void **remove_item** **(** :ref:`int<class_int>` idx **)**
  360. Removes the item at index "idx" from the menu. Note that the indexes of items after the removed item are going to be shifted by one.
  361. ----
  362. .. _class_PopupMenu_method_set_hide_on_window_lose_focus:
  363. - void **set_hide_on_window_lose_focus** **(** :ref:`bool<class_bool>` enable **)**
  364. Hides the :ref:`PopupMenu<class_PopupMenu>` when the window loses focus.
  365. ----
  366. .. _class_PopupMenu_method_set_item_accelerator:
  367. - void **set_item_accelerator** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` accel **)**
  368. Set the accelerator of the item at index "idx". Accelerators are special combinations of keys that activate the item, no matter which control is focused.
  369. ----
  370. .. _class_PopupMenu_method_set_item_as_checkable:
  371. - void **set_item_as_checkable** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  372. Sets whether the item at index ``idx`` has a checkbox. If ``false``, sets the type of the item to plain text.
  373. **Note:** Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
  374. ----
  375. .. _class_PopupMenu_method_set_item_as_radio_checkable:
  376. - void **set_item_as_radio_checkable** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  377. 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.
  378. ----
  379. .. _class_PopupMenu_method_set_item_as_separator:
  380. - void **set_item_as_separator** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  381. 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.
  382. ----
  383. .. _class_PopupMenu_method_set_item_checked:
  384. - void **set_item_checked** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` checked **)**
  385. Set the checkstate status of the item at index "idx".
  386. ----
  387. .. _class_PopupMenu_method_set_item_disabled:
  388. - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  389. Sets whether the item at index "idx" is disabled or not. When it is disabled it can't be selected, or its action invoked.
  390. ----
  391. .. _class_PopupMenu_method_set_item_icon:
  392. - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` icon **)**
  393. Replaces the :ref:`Texture<class_Texture>` icon of the specified ``idx``.
  394. ----
  395. .. _class_PopupMenu_method_set_item_id:
  396. - void **set_item_id** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)**
  397. Set the id of the item at index "idx".
  398. ----
  399. .. _class_PopupMenu_method_set_item_metadata:
  400. - void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)**
  401. Sets the metadata of an item, which might 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.
  402. ----
  403. .. _class_PopupMenu_method_set_item_multistate:
  404. - void **set_item_multistate** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` state **)**
  405. ----
  406. .. _class_PopupMenu_method_set_item_shortcut:
  407. - void **set_item_shortcut** **(** :ref:`int<class_int>` idx, :ref:`ShortCut<class_ShortCut>` shortcut, :ref:`bool<class_bool>` global=false **)**
  408. Sets a :ref:`ShortCut<class_ShortCut>` for the specified item ``idx``.
  409. ----
  410. .. _class_PopupMenu_method_set_item_shortcut_disabled:
  411. - void **set_item_shortcut_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  412. Disables the :ref:`ShortCut<class_ShortCut>` of the specified index ``idx``.
  413. ----
  414. .. _class_PopupMenu_method_set_item_submenu:
  415. - void **set_item_submenu** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` submenu **)**
  416. Sets the submenu of the item at index ``idx``. The submenu is the name of a child :ref:`PopupMenu<class_PopupMenu>` node that would be shown when the item is clicked.
  417. ----
  418. .. _class_PopupMenu_method_set_item_text:
  419. - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)**
  420. Set the text of the item at index "idx".
  421. ----
  422. .. _class_PopupMenu_method_set_item_tooltip:
  423. - void **set_item_tooltip** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` tooltip **)**
  424. Sets the :ref:`String<class_String>` tooltip of the item at the specified index ``idx``.
  425. ----
  426. .. _class_PopupMenu_method_toggle_item_checked:
  427. - void **toggle_item_checked** **(** :ref:`int<class_int>` idx **)**
  428. Toggles the check state of the item of the specified index ``idx``.
  429. ----
  430. .. _class_PopupMenu_method_toggle_item_multistate:
  431. - void **toggle_item_multistate** **(** :ref:`int<class_int>` idx **)**