class_itemlist.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the ItemList.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_ItemList:
  5. ItemList
  6. ========
  7. **Inherits:** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Control that provides a list of selectable items (and/or icons) in a single column, or optionally in multiple columns.
  12. Member Functions
  13. ----------------
  14. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`add_icon_item<class_ItemList_add_icon_item>` **(** :ref:`Texture<class_texture>` icon, :ref:`bool<class_bool>` selectable=true **)** |
  16. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`add_item<class_ItemList_add_item>` **(** :ref:`String<class_string>` text, :ref:`Texture<class_texture>` icon=null, :ref:`bool<class_bool>` selectable=true **)** |
  18. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`clear<class_ItemList_clear>` **(** **)** |
  20. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`ensure_current_is_visible<class_ItemList_ensure_current_is_visible>` **(** **)** |
  22. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`get_item_at_position<class_ItemList_get_item_at_position>` **(** :ref:`Vector2<class_vector2>` position, :ref:`bool<class_bool>` exact=false **)** const |
  24. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`get_item_count<class_ItemList_get_item_count>` **(** **)** const |
  26. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Color<class_color>` | :ref:`get_item_custom_bg_color<class_ItemList_get_item_custom_bg_color>` **(** :ref:`int<class_int>` idx **)** const |
  28. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Texture<class_texture>` | :ref:`get_item_icon<class_ItemList_get_item_icon>` **(** :ref:`int<class_int>` idx **)** const |
  30. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Rect2<class_rect2>` | :ref:`get_item_icon_region<class_ItemList_get_item_icon_region>` **(** :ref:`int<class_int>` idx **)** const |
  32. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Variant<class_variant>` | :ref:`get_item_metadata<class_ItemList_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** const |
  34. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`String<class_string>` | :ref:`get_item_text<class_ItemList_get_item_text>` **(** :ref:`int<class_int>` idx **)** const |
  36. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`String<class_string>` | :ref:`get_item_tooltip<class_ItemList_get_item_tooltip>` **(** :ref:`int<class_int>` idx **)** const |
  38. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`PoolIntArray<class_poolintarray>` | :ref:`get_selected_items<class_ItemList_get_selected_items>` **(** **)** |
  40. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`VScrollBar<class_vscrollbar>` | :ref:`get_v_scroll<class_ItemList_get_v_scroll>` **(** **)** |
  42. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_ItemList_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** const |
  44. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`is_item_selectable<class_ItemList_is_item_selectable>` **(** :ref:`int<class_int>` idx **)** const |
  46. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`is_item_tooltip_enabled<class_ItemList_is_item_tooltip_enabled>` **(** :ref:`int<class_int>` idx **)** const |
  48. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`is_selected<class_ItemList_is_selected>` **(** :ref:`int<class_int>` idx **)** const |
  50. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`remove_item<class_ItemList_remove_item>` **(** :ref:`int<class_int>` idx **)** |
  52. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`select<class_ItemList_select>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` single=true **)** |
  54. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_item_custom_bg_color<class_ItemList_set_item_custom_bg_color>` **(** :ref:`int<class_int>` idx, :ref:`Color<class_color>` custom_bg_color **)** |
  56. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_item_disabled<class_ItemList_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  58. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`set_item_icon<class_ItemList_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Texture<class_texture>` icon **)** |
  60. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_item_icon_region<class_ItemList_set_item_icon_region>` **(** :ref:`int<class_int>` idx, :ref:`Rect2<class_rect2>` rect **)** |
  62. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_item_metadata<class_ItemList_set_item_metadata>` **(** :ref:`int<class_int>` idx, :ref:`Variant<class_variant>` metadata **)** |
  64. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`set_item_selectable<class_ItemList_set_item_selectable>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` selectable **)** |
  66. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`set_item_text<class_ItemList_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)** |
  68. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`set_item_tooltip<class_ItemList_set_item_tooltip>` **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` tooltip **)** |
  70. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`set_item_tooltip_enabled<class_ItemList_set_item_tooltip_enabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)** |
  72. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`sort_items_by_text<class_ItemList_sort_items_by_text>` **(** **)** |
  74. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`unselect<class_ItemList_unselect>` **(** :ref:`int<class_int>` idx **)** |
  76. +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. Signals
  78. -------
  79. .. _class_ItemList_item_activated:
  80. - **item_activated** **(** :ref:`int<class_int>` index **)**
  81. Fired when specified list item is activated via double click or Enter.
  82. .. _class_ItemList_item_rmb_selected:
  83. - **item_rmb_selected** **(** :ref:`int<class_int>` index, :ref:`Vector2<class_vector2>` at_position **)**
  84. Fired when specified list item has been selected via right mouse clicking.
  85. The click position is also provided to allow appropriate popup of context menus
  86. at the correct location.
  87. .. _class_ItemList_item_selected:
  88. - **item_selected** **(** :ref:`int<class_int>` index **)**
  89. Fired when specified item has been selected.
  90. .. _class_ItemList_multi_selected:
  91. - **multi_selected** **(** :ref:`int<class_int>` index, :ref:`bool<class_bool>` selected **)**
  92. Fired when a multiple selection is altered on a list allowing multiple selection.
  93. .. _class_ItemList_nothing_selected:
  94. - **nothing_selected** **(** **)**
  95. .. _class_ItemList_rmb_clicked:
  96. - **rmb_clicked** **(** :ref:`Vector2<class_vector2>` at_position **)**
  97. Member Variables
  98. ----------------
  99. .. _class_ItemList_allow_reselect:
  100. - :ref:`bool<class_bool>` **allow_reselect** - If ``true`` the currently selected item may be selected again.
  101. .. _class_ItemList_allow_rmb_select:
  102. - :ref:`bool<class_bool>` **allow_rmb_select** - If ``true`` a right mouse button click can select items.
  103. .. _class_ItemList_auto_height:
  104. - :ref:`bool<class_bool>` **auto_height**
  105. .. _class_ItemList_fixed_column_width:
  106. - :ref:`int<class_int>` **fixed_column_width**
  107. .. _class_ItemList_fixed_icon_size:
  108. - :ref:`Vector2<class_vector2>` **fixed_icon_size**
  109. .. _class_ItemList_icon_mode:
  110. - :ref:`IconMode<enum_itemlist_iconmode>` **icon_mode**
  111. .. _class_ItemList_icon_scale:
  112. - :ref:`float<class_float>` **icon_scale**
  113. .. _class_ItemList_max_columns:
  114. - :ref:`int<class_int>` **max_columns**
  115. .. _class_ItemList_max_text_lines:
  116. - :ref:`int<class_int>` **max_text_lines**
  117. .. _class_ItemList_same_column_width:
  118. - :ref:`bool<class_bool>` **same_column_width**
  119. .. _class_ItemList_select_mode:
  120. - :ref:`SelectMode<enum_itemlist_selectmode>` **select_mode** - Allow single or multiple selection. See the ``SELECT_*`` constants.
  121. Enums
  122. -----
  123. .. _enum_ItemList_IconMode:
  124. enum **IconMode**
  125. - **ICON_MODE_TOP** = **0**
  126. - **ICON_MODE_LEFT** = **1**
  127. .. _enum_ItemList_SelectMode:
  128. enum **SelectMode**
  129. - **SELECT_SINGLE** = **0**
  130. - **SELECT_MULTI** = **1**
  131. Description
  132. -----------
  133. This control provides a selectable list of items that may be in a single (or multiple columns) with option of text, icons,
  134. or both text and icon. Tooltips are supported and may be different for every item in the list. Selectable items in the list
  135. may be selected or deselected and multiple selection may be enabled. Selection with right mouse button may also be enabled
  136. to allow use of popup context menus. Items may also be 'activated' with a double click (or Enter key).
  137. Member Function Description
  138. ---------------------------
  139. .. _class_ItemList_add_icon_item:
  140. - void **add_icon_item** **(** :ref:`Texture<class_texture>` icon, :ref:`bool<class_bool>` selectable=true **)**
  141. Adds an item to the item list with no text, only an icon.
  142. .. _class_ItemList_add_item:
  143. - void **add_item** **(** :ref:`String<class_string>` text, :ref:`Texture<class_texture>` icon=null, :ref:`bool<class_bool>` selectable=true **)**
  144. Adds an item to the item list with specified text. Specify an icon of null for a list item with no icon.
  145. If selectable is true the list item will be selectable.
  146. .. _class_ItemList_clear:
  147. - void **clear** **(** **)**
  148. Remove all items from the list.
  149. .. _class_ItemList_ensure_current_is_visible:
  150. - void **ensure_current_is_visible** **(** **)**
  151. Ensure selection is visible, adjusting the scroll position as necessary.
  152. .. _class_ItemList_get_item_at_position:
  153. - :ref:`int<class_int>` **get_item_at_position** **(** :ref:`Vector2<class_vector2>` position, :ref:`bool<class_bool>` exact=false **)** const
  154. Given a position within the control return the item (if any) at that point.
  155. .. _class_ItemList_get_item_count:
  156. - :ref:`int<class_int>` **get_item_count** **(** **)** const
  157. Return count of items currently in the item list.
  158. .. _class_ItemList_get_item_custom_bg_color:
  159. - :ref:`Color<class_color>` **get_item_custom_bg_color** **(** :ref:`int<class_int>` idx **)** const
  160. .. _class_ItemList_get_item_icon:
  161. - :ref:`Texture<class_texture>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** const
  162. .. _class_ItemList_get_item_icon_region:
  163. - :ref:`Rect2<class_rect2>` **get_item_icon_region** **(** :ref:`int<class_int>` idx **)** const
  164. .. _class_ItemList_get_item_metadata:
  165. - :ref:`Variant<class_variant>` **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
  166. .. _class_ItemList_get_item_text:
  167. - :ref:`String<class_string>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
  168. Return the text for specified item index.
  169. .. _class_ItemList_get_item_tooltip:
  170. - :ref:`String<class_string>` **get_item_tooltip** **(** :ref:`int<class_int>` idx **)** const
  171. Return tooltip hint for specified item index.
  172. .. _class_ItemList_get_selected_items:
  173. - :ref:`PoolIntArray<class_poolintarray>` **get_selected_items** **(** **)**
  174. Returns the list of selected indexes.
  175. .. _class_ItemList_get_v_scroll:
  176. - :ref:`VScrollBar<class_vscrollbar>` **get_v_scroll** **(** **)**
  177. Returns the current vertical scroll bar for the List.
  178. .. _class_ItemList_is_item_disabled:
  179. - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
  180. Returns whether or not the item at the specified index is disabled
  181. .. _class_ItemList_is_item_selectable:
  182. - :ref:`bool<class_bool>` **is_item_selectable** **(** :ref:`int<class_int>` idx **)** const
  183. Returns whether or not the item at the specified index is selectable.
  184. .. _class_ItemList_is_item_tooltip_enabled:
  185. - :ref:`bool<class_bool>` **is_item_tooltip_enabled** **(** :ref:`int<class_int>` idx **)** const
  186. Returns whether the tooltip is enabled for specified item index.
  187. .. _class_ItemList_is_selected:
  188. - :ref:`bool<class_bool>` **is_selected** **(** :ref:`int<class_int>` idx **)** const
  189. Returns whether or not item at the specified index is currently selected.
  190. .. _class_ItemList_remove_item:
  191. - void **remove_item** **(** :ref:`int<class_int>` idx **)**
  192. Remove item at specified index from the list.
  193. .. _class_ItemList_select:
  194. - void **select** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` single=true **)**
  195. Select the item at the specified index.
  196. Note: This method does not trigger the item selection signal.
  197. .. _class_ItemList_set_item_custom_bg_color:
  198. - void **set_item_custom_bg_color** **(** :ref:`int<class_int>` idx, :ref:`Color<class_color>` custom_bg_color **)**
  199. .. _class_ItemList_set_item_disabled:
  200. - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  201. Disable (or enable) item at specified index.
  202. Disabled items are not be selectable and do not fire activation (Enter or double-click) signals.
  203. .. _class_ItemList_set_item_icon:
  204. - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_texture>` icon **)**
  205. Set (or replace) icon of the item at the specified index.
  206. .. _class_ItemList_set_item_icon_region:
  207. - void **set_item_icon_region** **(** :ref:`int<class_int>` idx, :ref:`Rect2<class_rect2>` rect **)**
  208. .. _class_ItemList_set_item_metadata:
  209. - void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_variant>` metadata **)**
  210. Sets a value (of any type) to be stored with the item at the specified index.
  211. .. _class_ItemList_set_item_selectable:
  212. - void **set_item_selectable** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` selectable **)**
  213. Allow or disallow selection of the item at the specified index.
  214. .. _class_ItemList_set_item_text:
  215. - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)**
  216. Sets text of item at specified index.
  217. .. _class_ItemList_set_item_tooltip:
  218. - void **set_item_tooltip** **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` tooltip **)**
  219. Sets tooltip hint for item at specified index.
  220. .. _class_ItemList_set_item_tooltip_enabled:
  221. - void **set_item_tooltip_enabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  222. Sets whether the tooltip is enabled for specified item index.
  223. .. _class_ItemList_sort_items_by_text:
  224. - void **sort_items_by_text** **(** **)**
  225. Sorts items in the list by their text.
  226. .. _class_ItemList_unselect:
  227. - void **unselect** **(** :ref:`int<class_int>` idx **)**
  228. Ensure item at specified index is not selected.