class_popupmenu.rst 52 KB

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