class_popupmenu.rst 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_PopupMenu:
  4. PopupMenu
  5. =========
  6. **Inherits:** :ref:`Popup<class_popup>` **<** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. PopupMenu displays a list of options.
  11. Member Functions
  12. ----------------
  13. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`add_check_item<class_PopupMenu_add_check_item>` **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  15. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`add_check_shortcut<class_PopupMenu_add_check_shortcut>` **(** :ref:`ShortCut<class_shortcut>` shortcut, :ref:`int<class_int>` id=-1 **)** |
  17. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`add_icon_check_item<class_PopupMenu_add_icon_check_item>` **(** :ref:`Object<class_object>` texture, :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  19. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`add_icon_check_shortcut<class_PopupMenu_add_icon_check_shortcut>` **(** :ref:`Object<class_object>` texture, :ref:`ShortCut<class_shortcut>` shortcut, :ref:`int<class_int>` id=-1 **)** |
  21. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`add_icon_item<class_PopupMenu_add_icon_item>` **(** :ref:`Object<class_object>` texture, :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  23. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`add_icon_shortcut<class_PopupMenu_add_icon_shortcut>` **(** :ref:`Object<class_object>` texture, :ref:`ShortCut<class_shortcut>` shortcut, :ref:`int<class_int>` id=-1 **)** |
  25. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`add_item<class_PopupMenu_add_item>` **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)** |
  27. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`add_separator<class_PopupMenu_add_separator>` **(** **)** |
  29. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`add_shortcut<class_PopupMenu_add_shortcut>` **(** :ref:`ShortCut<class_shortcut>` shortcut, :ref:`int<class_int>` id=-1 **)** |
  31. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`add_submenu_item<class_PopupMenu_add_submenu_item>` **(** :ref:`String<class_string>` label, :ref:`String<class_string>` submenu, :ref:`int<class_int>` id=-1 **)** |
  33. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`clear<class_PopupMenu_clear>` **(** **)** |
  35. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`get_item_ID<class_PopupMenu_get_item_ID>` **(** :ref:`int<class_int>` idx **)** const |
  37. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_item_accelerator<class_PopupMenu_get_item_accelerator>` **(** :ref:`int<class_int>` idx **)** const |
  39. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`get_item_count<class_PopupMenu_get_item_count>` **(** **)** const |
  41. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Object<class_object>` | :ref:`get_item_icon<class_PopupMenu_get_item_icon>` **(** :ref:`int<class_int>` idx **)** const |
  43. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`int<class_int>` | :ref:`get_item_index<class_PopupMenu_get_item_index>` **(** :ref:`int<class_int>` id **)** const |
  45. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`get_item_metadata<class_PopupMenu_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** const |
  47. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`ShortCut<class_shortcut>` | :ref:`get_item_shortcut<class_PopupMenu_get_item_shortcut>` **(** :ref:`int<class_int>` idx **)** const |
  49. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`String<class_string>` | :ref:`get_item_submenu<class_PopupMenu_get_item_submenu>` **(** :ref:`int<class_int>` idx **)** const |
  51. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`String<class_string>` | :ref:`get_item_text<class_PopupMenu_get_item_text>` **(** :ref:`int<class_int>` idx **)** const |
  53. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`String<class_string>` | :ref:`get_item_tooltip<class_PopupMenu_get_item_tooltip>` **(** :ref:`int<class_int>` idx **)** const |
  55. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`is_hide_on_item_selection<class_PopupMenu_is_hide_on_item_selection>` **(** **)** |
  57. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`bool<class_bool>` | :ref:`is_item_checkable<class_PopupMenu_is_item_checkable>` **(** :ref:`int<class_int>` idx **)** const |
  59. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`bool<class_bool>` | :ref:`is_item_checked<class_PopupMenu_is_item_checked>` **(** :ref:`int<class_int>` idx **)** const |
  61. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_PopupMenu_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** const |
  63. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`bool<class_bool>` | :ref:`is_item_separator<class_PopupMenu_is_item_separator>` **(** :ref:`int<class_int>` idx **)** const |
  65. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`remove_item<class_PopupMenu_remove_item>` **(** :ref:`int<class_int>` idx **)** |
  67. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`set_hide_on_item_selection<class_PopupMenu_set_hide_on_item_selection>` **(** :ref:`bool<class_bool>` enable **)** |
  69. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`set_item_ID<class_PopupMenu_set_item_ID>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)** |
  71. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`set_item_accelerator<class_PopupMenu_set_item_accelerator>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` accel **)** |
  73. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`set_item_as_checkable<class_PopupMenu_set_item_as_checkable>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)** |
  75. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`set_item_as_separator<class_PopupMenu_set_item_as_separator>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)** |
  77. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`set_item_checked<class_PopupMenu_set_item_checked>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` checked **)** |
  79. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`set_item_disabled<class_PopupMenu_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  81. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | void | :ref:`set_item_icon<class_PopupMenu_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Object<class_object>` icon **)** |
  83. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | void | :ref:`set_item_metadata<class_PopupMenu_set_item_metadata>` **(** :ref:`int<class_int>` idx, :ref:`Variant<class_variant>` metadata **)** |
  85. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | void | :ref:`set_item_shortcut<class_PopupMenu_set_item_shortcut>` **(** :ref:`int<class_int>` idx, :ref:`ShortCut<class_shortcut>` shortcut **)** |
  87. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | void | :ref:`set_item_submenu<class_PopupMenu_set_item_submenu>` **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` submenu **)** |
  89. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`set_item_text<class_PopupMenu_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)** |
  91. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`set_item_tooltip<class_PopupMenu_set_item_tooltip>` **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` tooltip **)** |
  93. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | void | :ref:`toggle_item_checked<class_PopupMenu_toggle_item_checked>` **(** :ref:`int<class_int>` idx **)** |
  95. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. Signals
  97. -------
  98. - **item_pressed** **(** :ref:`int<class_int>` ID **)**
  99. This even is emitted when an item is pressed or its accelerator is activated. The id of the item is returned if it exists, else the index.
  100. Description
  101. -----------
  102. PopupMenu is the typical Control that displays a list of options. They are popular in toolbars or context menus.
  103. Member Function Description
  104. ---------------------------
  105. .. _class_PopupMenu_add_check_item:
  106. - void **add_check_item** **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  107. Add a new checkable item with text "label". An id can optionally be provided, as well as an accelerator. If no id is provided, one will be created from the index. Note that checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
  108. .. _class_PopupMenu_add_check_shortcut:
  109. - void **add_check_shortcut** **(** :ref:`ShortCut<class_shortcut>` shortcut, :ref:`int<class_int>` id=-1 **)**
  110. .. _class_PopupMenu_add_icon_check_item:
  111. - void **add_icon_check_item** **(** :ref:`Object<class_object>` texture, :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  112. Add a new checkable item with text "label" and icon "texture". An id can optionally be provided, as well as an accelerator. If no id is provided, one will be created from the index. Note that checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
  113. .. _class_PopupMenu_add_icon_check_shortcut:
  114. - void **add_icon_check_shortcut** **(** :ref:`Object<class_object>` texture, :ref:`ShortCut<class_shortcut>` shortcut, :ref:`int<class_int>` id=-1 **)**
  115. .. _class_PopupMenu_add_icon_item:
  116. - void **add_icon_item** **(** :ref:`Object<class_object>` texture, :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  117. Add a new item with text "label" and icon "texture". An id can optionally be provided, as well as an accelerator keybinding. If no id is provided, one will be created from the index.
  118. .. _class_PopupMenu_add_icon_shortcut:
  119. - void **add_icon_shortcut** **(** :ref:`Object<class_object>` texture, :ref:`ShortCut<class_shortcut>` shortcut, :ref:`int<class_int>` id=-1 **)**
  120. .. _class_PopupMenu_add_item:
  121. - void **add_item** **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1, :ref:`int<class_int>` accel=0 **)**
  122. Add a new item with text "label". An id can optionally be provided, as well as an accelerator keybinding. If no id is provided, one will be created from the index.
  123. .. _class_PopupMenu_add_separator:
  124. - void **add_separator** **(** **)**
  125. Add a separator between items. Separators also occupy an index.
  126. .. _class_PopupMenu_add_shortcut:
  127. - void **add_shortcut** **(** :ref:`ShortCut<class_shortcut>` shortcut, :ref:`int<class_int>` id=-1 **)**
  128. .. _class_PopupMenu_add_submenu_item:
  129. - void **add_submenu_item** **(** :ref:`String<class_string>` label, :ref:`String<class_string>` submenu, :ref:`int<class_int>` id=-1 **)**
  130. Adds an item with a submenu. The submenu is the name of a child PopupMenu node that would be shown when the item is clicked. An id can optionally be provided, but if is isn't provided, one will be created from the index.
  131. .. _class_PopupMenu_clear:
  132. - void **clear** **(** **)**
  133. Clear the popup menu, in effect removing all items.
  134. .. _class_PopupMenu_get_item_ID:
  135. - :ref:`int<class_int>` **get_item_ID** **(** :ref:`int<class_int>` idx **)** const
  136. Return the id of the item at index "idx".
  137. .. _class_PopupMenu_get_item_accelerator:
  138. - :ref:`int<class_int>` **get_item_accelerator** **(** :ref:`int<class_int>` idx **)** const
  139. Return the accelerator of the item at index "idx". Accelerators are special combinations of keys that activate the item, no matter which control is focused.
  140. .. _class_PopupMenu_get_item_count:
  141. - :ref:`int<class_int>` **get_item_count** **(** **)** const
  142. Return the amount of items.
  143. .. _class_PopupMenu_get_item_icon:
  144. - :ref:`Object<class_object>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** const
  145. Return the icon of the item at index "idx".
  146. .. _class_PopupMenu_get_item_index:
  147. - :ref:`int<class_int>` **get_item_index** **(** :ref:`int<class_int>` id **)** const
  148. Find and return the index of the item containing a given id.
  149. .. _class_PopupMenu_get_item_metadata:
  150. - void **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
  151. Return the metadata of an item, which might be of any type. You can set it with :ref:`set_item_metadata<class_PopupMenu_set_item_metadata>`, which provides a simple way of assigning context data to items.
  152. .. _class_PopupMenu_get_item_shortcut:
  153. - :ref:`ShortCut<class_shortcut>` **get_item_shortcut** **(** :ref:`int<class_int>` idx **)** const
  154. .. _class_PopupMenu_get_item_submenu:
  155. - :ref:`String<class_string>` **get_item_submenu** **(** :ref:`int<class_int>` idx **)** const
  156. Return the submenu name of the item at index "idx".
  157. .. _class_PopupMenu_get_item_text:
  158. - :ref:`String<class_string>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
  159. Return the text of the item at index "idx".
  160. .. _class_PopupMenu_get_item_tooltip:
  161. - :ref:`String<class_string>` **get_item_tooltip** **(** :ref:`int<class_int>` idx **)** const
  162. .. _class_PopupMenu_is_hide_on_item_selection:
  163. - :ref:`bool<class_bool>` **is_hide_on_item_selection** **(** **)**
  164. Returns a boolean that indicates whether or not the PopupMenu will hide on item selection.
  165. .. _class_PopupMenu_is_item_checkable:
  166. - :ref:`bool<class_bool>` **is_item_checkable** **(** :ref:`int<class_int>` idx **)** const
  167. Return whether the item at index "idx" has a checkbox. Note that checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
  168. .. _class_PopupMenu_is_item_checked:
  169. - :ref:`bool<class_bool>` **is_item_checked** **(** :ref:`int<class_int>` idx **)** const
  170. Return the checkstate status of the item at index "idx".
  171. .. _class_PopupMenu_is_item_disabled:
  172. - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
  173. Return whether the item at index "idx" is disabled. When it is disabled it can't be selected, or its action invoked.
  174. .. _class_PopupMenu_is_item_separator:
  175. - :ref:`bool<class_bool>` **is_item_separator** **(** :ref:`int<class_int>` idx **)** const
  176. Return whether the item is a seperator. If it is, it would be displayed as a line.
  177. .. _class_PopupMenu_remove_item:
  178. - void **remove_item** **(** :ref:`int<class_int>` idx **)**
  179. 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.
  180. .. _class_PopupMenu_set_hide_on_item_selection:
  181. - void **set_hide_on_item_selection** **(** :ref:`bool<class_bool>` enable **)**
  182. Sets whether or not the PopupMenu will hide on item selection.
  183. .. _class_PopupMenu_set_item_ID:
  184. - void **set_item_ID** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)**
  185. Set the id of the item at index "idx".
  186. .. _class_PopupMenu_set_item_accelerator:
  187. - void **set_item_accelerator** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` accel **)**
  188. 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.
  189. .. _class_PopupMenu_set_item_as_checkable:
  190. - void **set_item_as_checkable** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  191. Set whether the item at index "idx" has a checkbox. Note that checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
  192. .. _class_PopupMenu_set_item_as_separator:
  193. - void **set_item_as_separator** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  194. Mark the item at index "idx" as a seperator, which means that it would be displayed as a mere line.
  195. .. _class_PopupMenu_set_item_checked:
  196. - void **set_item_checked** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` checked **)**
  197. Set the checkstate status of the item at index "idx".
  198. .. _class_PopupMenu_set_item_disabled:
  199. - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  200. Sets whether the item at index "idx" is disabled or not. When it is disabled it can't be selected, or its action invoked.
  201. .. _class_PopupMenu_set_item_icon:
  202. - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Object<class_object>` icon **)**
  203. Set the icon of the item at index "idx".
  204. .. _class_PopupMenu_set_item_metadata:
  205. - void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_variant>` metadata **)**
  206. Sets the metadata of an item, which might be of any type. You can later get it with :ref:`get_item_metadata<class_PopupMenu_get_item_metadata>`, which provides a simple way of assigning context data to items.
  207. .. _class_PopupMenu_set_item_shortcut:
  208. - void **set_item_shortcut** **(** :ref:`int<class_int>` idx, :ref:`ShortCut<class_shortcut>` shortcut **)**
  209. .. _class_PopupMenu_set_item_submenu:
  210. - void **set_item_submenu** **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` submenu **)**
  211. 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.
  212. .. _class_PopupMenu_set_item_text:
  213. - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)**
  214. Set the text of the item at index "idx".
  215. .. _class_PopupMenu_set_item_tooltip:
  216. - void **set_item_tooltip** **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` tooltip **)**
  217. .. _class_PopupMenu_toggle_item_checked:
  218. - void **toggle_item_checked** **(** :ref:`int<class_int>` idx **)**