class_itemlist.rst 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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 ItemList.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_ItemList:
  6. ItemList
  7. ========
  8. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Control that provides a list of selectable items (and/or icons) in a single column, or optionally in multiple columns.
  13. Properties
  14. ----------
  15. +---------------------------------------------+-----------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`allow_reselect<class_ItemList_property_allow_reselect>` |
  17. +---------------------------------------------+-----------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`allow_rmb_select<class_ItemList_property_allow_rmb_select>` |
  19. +---------------------------------------------+-----------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`auto_height<class_ItemList_property_auto_height>` |
  21. +---------------------------------------------+-----------------------------------------------------------------------+
  22. | :ref:`int<class_int>` | :ref:`fixed_column_width<class_ItemList_property_fixed_column_width>` |
  23. +---------------------------------------------+-----------------------------------------------------------------------+
  24. | :ref:`Vector2<class_Vector2>` | :ref:`fixed_icon_size<class_ItemList_property_fixed_icon_size>` |
  25. +---------------------------------------------+-----------------------------------------------------------------------+
  26. | :ref:`IconMode<enum_ItemList_IconMode>` | :ref:`icon_mode<class_ItemList_property_icon_mode>` |
  27. +---------------------------------------------+-----------------------------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`icon_scale<class_ItemList_property_icon_scale>` |
  29. +---------------------------------------------+-----------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`max_columns<class_ItemList_property_max_columns>` |
  31. +---------------------------------------------+-----------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`max_text_lines<class_ItemList_property_max_text_lines>` |
  33. +---------------------------------------------+-----------------------------------------------------------------------+
  34. | :ref:`bool<class_bool>` | :ref:`same_column_width<class_ItemList_property_same_column_width>` |
  35. +---------------------------------------------+-----------------------------------------------------------------------+
  36. | :ref:`SelectMode<enum_ItemList_SelectMode>` | :ref:`select_mode<class_ItemList_property_select_mode>` |
  37. +---------------------------------------------+-----------------------------------------------------------------------+
  38. Methods
  39. -------
  40. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`add_icon_item<class_ItemList_method_add_icon_item>` **(** :ref:`Texture<class_Texture>` icon, :ref:`bool<class_bool>` selectable=true **)** |
  42. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`add_item<class_ItemList_method_add_item>` **(** :ref:`String<class_String>` text, :ref:`Texture<class_Texture>` icon=null, :ref:`bool<class_bool>` selectable=true **)** |
  44. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`clear<class_ItemList_method_clear>` **(** **)** |
  46. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`ensure_current_is_visible<class_ItemList_method_ensure_current_is_visible>` **(** **)** |
  48. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`int<class_int>` | :ref:`get_item_at_position<class_ItemList_method_get_item_at_position>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`bool<class_bool>` exact=false **)** const |
  50. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`get_item_count<class_ItemList_method_get_item_count>` **(** **)** const |
  52. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Color<class_Color>` | :ref:`get_item_custom_bg_color<class_ItemList_method_get_item_custom_bg_color>` **(** :ref:`int<class_int>` idx **)** const |
  54. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Color<class_Color>` | :ref:`get_item_custom_fg_color<class_ItemList_method_get_item_custom_fg_color>` **(** :ref:`int<class_int>` idx **)** const |
  56. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Texture<class_Texture>` | :ref:`get_item_icon<class_ItemList_method_get_item_icon>` **(** :ref:`int<class_int>` idx **)** const |
  58. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Color<class_Color>` | :ref:`get_item_icon_modulate<class_ItemList_method_get_item_icon_modulate>` **(** :ref:`int<class_int>` idx **)** const |
  60. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`Rect2<class_Rect2>` | :ref:`get_item_icon_region<class_ItemList_method_get_item_icon_region>` **(** :ref:`int<class_int>` idx **)** const |
  62. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Variant<class_Variant>` | :ref:`get_item_metadata<class_ItemList_method_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** const |
  64. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`String<class_String>` | :ref:`get_item_text<class_ItemList_method_get_item_text>` **(** :ref:`int<class_int>` idx **)** const |
  66. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`String<class_String>` | :ref:`get_item_tooltip<class_ItemList_method_get_item_tooltip>` **(** :ref:`int<class_int>` idx **)** const |
  68. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`PoolIntArray<class_PoolIntArray>` | :ref:`get_selected_items<class_ItemList_method_get_selected_items>` **(** **)** |
  70. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`VScrollBar<class_VScrollBar>` | :ref:`get_v_scroll<class_ItemList_method_get_v_scroll>` **(** **)** |
  72. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`is_anything_selected<class_ItemList_method_is_anything_selected>` **(** **)** |
  74. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_ItemList_method_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** const |
  76. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`bool<class_bool>` | :ref:`is_item_icon_transposed<class_ItemList_method_is_item_icon_transposed>` **(** :ref:`int<class_int>` idx **)** const |
  78. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`is_item_selectable<class_ItemList_method_is_item_selectable>` **(** :ref:`int<class_int>` idx **)** const |
  80. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`bool<class_bool>` | :ref:`is_item_tooltip_enabled<class_ItemList_method_is_item_tooltip_enabled>` **(** :ref:`int<class_int>` idx **)** const |
  82. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`bool<class_bool>` | :ref:`is_selected<class_ItemList_method_is_selected>` **(** :ref:`int<class_int>` idx **)** const |
  84. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`move_item<class_ItemList_method_move_item>` **(** :ref:`int<class_int>` from_idx, :ref:`int<class_int>` to_idx **)** |
  86. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`remove_item<class_ItemList_method_remove_item>` **(** :ref:`int<class_int>` idx **)** |
  88. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`select<class_ItemList_method_select>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` single=true **)** |
  90. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`set_item_custom_bg_color<class_ItemList_method_set_item_custom_bg_color>` **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` custom_bg_color **)** |
  92. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`set_item_custom_fg_color<class_ItemList_method_set_item_custom_fg_color>` **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` custom_fg_color **)** |
  94. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`set_item_disabled<class_ItemList_method_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  96. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`set_item_icon<class_ItemList_method_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` icon **)** |
  98. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`set_item_icon_modulate<class_ItemList_method_set_item_icon_modulate>` **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` modulate **)** |
  100. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`set_item_icon_region<class_ItemList_method_set_item_icon_region>` **(** :ref:`int<class_int>` idx, :ref:`Rect2<class_Rect2>` rect **)** |
  102. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`set_item_icon_transposed<class_ItemList_method_set_item_icon_transposed>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` rect **)** |
  104. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`set_item_metadata<class_ItemList_method_set_item_metadata>` **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)** |
  106. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`set_item_selectable<class_ItemList_method_set_item_selectable>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` selectable **)** |
  108. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`set_item_text<class_ItemList_method_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)** |
  110. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | void | :ref:`set_item_tooltip<class_ItemList_method_set_item_tooltip>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` tooltip **)** |
  112. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`set_item_tooltip_enabled<class_ItemList_method_set_item_tooltip_enabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)** |
  114. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`sort_items_by_text<class_ItemList_method_sort_items_by_text>` **(** **)** |
  116. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`unselect<class_ItemList_method_unselect>` **(** :ref:`int<class_int>` idx **)** |
  118. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`unselect_all<class_ItemList_method_unselect_all>` **(** **)** |
  120. +-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. Theme Properties
  122. ----------------
  123. +---------------------------------+---------------------+
  124. | :ref:`StyleBox<class_StyleBox>` | bg |
  125. +---------------------------------+---------------------+
  126. | :ref:`StyleBox<class_StyleBox>` | bg_focus |
  127. +---------------------------------+---------------------+
  128. | :ref:`StyleBox<class_StyleBox>` | cursor |
  129. +---------------------------------+---------------------+
  130. | :ref:`StyleBox<class_StyleBox>` | cursor_unfocused |
  131. +---------------------------------+---------------------+
  132. | :ref:`Font<class_Font>` | font |
  133. +---------------------------------+---------------------+
  134. | :ref:`Color<class_Color>` | font_color |
  135. +---------------------------------+---------------------+
  136. | :ref:`Color<class_Color>` | font_color_selected |
  137. +---------------------------------+---------------------+
  138. | :ref:`Color<class_Color>` | guide_color |
  139. +---------------------------------+---------------------+
  140. | :ref:`int<class_int>` | hseparation |
  141. +---------------------------------+---------------------+
  142. | :ref:`int<class_int>` | icon_margin |
  143. +---------------------------------+---------------------+
  144. | :ref:`int<class_int>` | line_separation |
  145. +---------------------------------+---------------------+
  146. | :ref:`StyleBox<class_StyleBox>` | selected |
  147. +---------------------------------+---------------------+
  148. | :ref:`StyleBox<class_StyleBox>` | selected_focus |
  149. +---------------------------------+---------------------+
  150. | :ref:`int<class_int>` | vseparation |
  151. +---------------------------------+---------------------+
  152. Signals
  153. -------
  154. .. _class_ItemList_signal_item_activated:
  155. - **item_activated** **(** :ref:`int<class_int>` index **)**
  156. Triggered when specified list item is activated via double click or Enter.
  157. ----
  158. .. _class_ItemList_signal_item_rmb_selected:
  159. - **item_rmb_selected** **(** :ref:`int<class_int>` index, :ref:`Vector2<class_Vector2>` at_position **)**
  160. Triggered when specified list item has been selected via right mouse clicking.
  161. The click position is also provided to allow appropriate popup of context menus
  162. at the correct location.
  163. :ref:`allow_rmb_select<class_ItemList_property_allow_rmb_select>` must be enabled.
  164. ----
  165. .. _class_ItemList_signal_item_selected:
  166. - **item_selected** **(** :ref:`int<class_int>` index **)**
  167. Triggered when specified item has been selected.
  168. :ref:`allow_reselect<class_ItemList_property_allow_reselect>` must be enabled to reselect an item.
  169. ----
  170. .. _class_ItemList_signal_multi_selected:
  171. - **multi_selected** **(** :ref:`int<class_int>` index, :ref:`bool<class_bool>` selected **)**
  172. Triggered when a multiple selection is altered on a list allowing multiple selection.
  173. ----
  174. .. _class_ItemList_signal_nothing_selected:
  175. - **nothing_selected** **(** **)**
  176. Triggered when a left mouse click is issued within the rect of the list but on empty space.
  177. ----
  178. .. _class_ItemList_signal_rmb_clicked:
  179. - **rmb_clicked** **(** :ref:`Vector2<class_Vector2>` at_position **)**
  180. Triggered when a right mouse click is issued within the rect of the list but on empty space.
  181. :ref:`allow_rmb_select<class_ItemList_property_allow_rmb_select>` must be enabled.
  182. Enumerations
  183. ------------
  184. .. _enum_ItemList_IconMode:
  185. .. _class_ItemList_constant_ICON_MODE_TOP:
  186. .. _class_ItemList_constant_ICON_MODE_LEFT:
  187. enum **IconMode**:
  188. - **ICON_MODE_TOP** = **0**
  189. - **ICON_MODE_LEFT** = **1**
  190. ----
  191. .. _enum_ItemList_SelectMode:
  192. .. _class_ItemList_constant_SELECT_SINGLE:
  193. .. _class_ItemList_constant_SELECT_MULTI:
  194. enum **SelectMode**:
  195. - **SELECT_SINGLE** = **0**
  196. - **SELECT_MULTI** = **1**
  197. Description
  198. -----------
  199. This control provides a selectable list of items that may be in a single (or multiple columns) with option of text, icons, or both text and icon. Tooltips are supported and may be different for every item in the list.
  200. Selectable items in the list may be selected or deselected and multiple selection may be enabled. Selection with right mouse button may also be enabled to allow use of popup context menus. Items may also be 'activated' with a double click (or Enter key).
  201. Property Descriptions
  202. ---------------------
  203. .. _class_ItemList_property_allow_reselect:
  204. - :ref:`bool<class_bool>` **allow_reselect**
  205. +----------+---------------------------+
  206. | *Setter* | set_allow_reselect(value) |
  207. +----------+---------------------------+
  208. | *Getter* | get_allow_reselect() |
  209. +----------+---------------------------+
  210. If ``true``, the currently selected item can be selected again.
  211. ----
  212. .. _class_ItemList_property_allow_rmb_select:
  213. - :ref:`bool<class_bool>` **allow_rmb_select**
  214. +----------+-----------------------------+
  215. | *Setter* | set_allow_rmb_select(value) |
  216. +----------+-----------------------------+
  217. | *Getter* | get_allow_rmb_select() |
  218. +----------+-----------------------------+
  219. If ``true``, right mouse button click can select items.
  220. ----
  221. .. _class_ItemList_property_auto_height:
  222. - :ref:`bool<class_bool>` **auto_height**
  223. +----------+------------------------+
  224. | *Setter* | set_auto_height(value) |
  225. +----------+------------------------+
  226. | *Getter* | has_auto_height() |
  227. +----------+------------------------+
  228. If ``true``, the control will automatically resize the height to fit its content.
  229. ----
  230. .. _class_ItemList_property_fixed_column_width:
  231. - :ref:`int<class_int>` **fixed_column_width**
  232. +----------+-------------------------------+
  233. | *Setter* | set_fixed_column_width(value) |
  234. +----------+-------------------------------+
  235. | *Getter* | get_fixed_column_width() |
  236. +----------+-------------------------------+
  237. Sets the default column width in pixels.
  238. If left to default value, each item will have a width equal to the width of its content and the columns will have an uneven width.
  239. ----
  240. .. _class_ItemList_property_fixed_icon_size:
  241. - :ref:`Vector2<class_Vector2>` **fixed_icon_size**
  242. +----------+----------------------------+
  243. | *Setter* | set_fixed_icon_size(value) |
  244. +----------+----------------------------+
  245. | *Getter* | get_fixed_icon_size() |
  246. +----------+----------------------------+
  247. Sets the default icon size in pixels.
  248. ----
  249. .. _class_ItemList_property_icon_mode:
  250. - :ref:`IconMode<enum_ItemList_IconMode>` **icon_mode**
  251. +----------+----------------------+
  252. | *Setter* | set_icon_mode(value) |
  253. +----------+----------------------+
  254. | *Getter* | get_icon_mode() |
  255. +----------+----------------------+
  256. Sets the default position of the icon to either :ref:`ICON_MODE_LEFT<class_ItemList_constant_ICON_MODE_LEFT>` or :ref:`ICON_MODE_TOP<class_ItemList_constant_ICON_MODE_TOP>`.
  257. ----
  258. .. _class_ItemList_property_icon_scale:
  259. - :ref:`float<class_float>` **icon_scale**
  260. +----------+-----------------------+
  261. | *Setter* | set_icon_scale(value) |
  262. +----------+-----------------------+
  263. | *Getter* | get_icon_scale() |
  264. +----------+-----------------------+
  265. Sets the icon size to its initial size multiplied by the specified scale. Default value is 1.0.
  266. ----
  267. .. _class_ItemList_property_max_columns:
  268. - :ref:`int<class_int>` **max_columns**
  269. +----------+------------------------+
  270. | *Setter* | set_max_columns(value) |
  271. +----------+------------------------+
  272. | *Getter* | get_max_columns() |
  273. +----------+------------------------+
  274. Sets the maximum columns the list will have.
  275. If set to anything other than the default, the content will be split among the specified columns.
  276. ----
  277. .. _class_ItemList_property_max_text_lines:
  278. - :ref:`int<class_int>` **max_text_lines**
  279. +----------+---------------------------+
  280. | *Setter* | set_max_text_lines(value) |
  281. +----------+---------------------------+
  282. | *Getter* | get_max_text_lines() |
  283. +----------+---------------------------+
  284. ----
  285. .. _class_ItemList_property_same_column_width:
  286. - :ref:`bool<class_bool>` **same_column_width**
  287. +----------+------------------------------+
  288. | *Setter* | set_same_column_width(value) |
  289. +----------+------------------------------+
  290. | *Getter* | is_same_column_width() |
  291. +----------+------------------------------+
  292. If set to ``true``, all columns will have the same width specified by :ref:`fixed_column_width<class_ItemList_property_fixed_column_width>`.
  293. ----
  294. .. _class_ItemList_property_select_mode:
  295. - :ref:`SelectMode<enum_ItemList_SelectMode>` **select_mode**
  296. +----------+------------------------+
  297. | *Setter* | set_select_mode(value) |
  298. +----------+------------------------+
  299. | *Getter* | get_select_mode() |
  300. +----------+------------------------+
  301. Allow single or multiple item selection. See the ``SELECT_*`` constants.
  302. Method Descriptions
  303. -------------------
  304. .. _class_ItemList_method_add_icon_item:
  305. - void **add_icon_item** **(** :ref:`Texture<class_Texture>` icon, :ref:`bool<class_bool>` selectable=true **)**
  306. Adds an item to the item list with no text, only an icon.
  307. ----
  308. .. _class_ItemList_method_add_item:
  309. - void **add_item** **(** :ref:`String<class_String>` text, :ref:`Texture<class_Texture>` icon=null, :ref:`bool<class_bool>` selectable=true **)**
  310. Adds an item to the item list with specified text. Specify an icon of null for a list item with no icon.
  311. If selectable is ``true`` the list item will be selectable.
  312. ----
  313. .. _class_ItemList_method_clear:
  314. - void **clear** **(** **)**
  315. Remove all items from the list.
  316. ----
  317. .. _class_ItemList_method_ensure_current_is_visible:
  318. - void **ensure_current_is_visible** **(** **)**
  319. Ensure current selection is visible, adjusting the scroll position as necessary.
  320. ----
  321. .. _class_ItemList_method_get_item_at_position:
  322. - :ref:`int<class_int>` **get_item_at_position** **(** :ref:`Vector2<class_Vector2>` position, :ref:`bool<class_bool>` exact=false **)** const
  323. Given a position within the control return the item (if any) at that point.
  324. ----
  325. .. _class_ItemList_method_get_item_count:
  326. - :ref:`int<class_int>` **get_item_count** **(** **)** const
  327. Returns the number of items currently in the list.
  328. ----
  329. .. _class_ItemList_method_get_item_custom_bg_color:
  330. - :ref:`Color<class_Color>` **get_item_custom_bg_color** **(** :ref:`int<class_int>` idx **)** const
  331. Returns the :ref:`Color<class_Color>` set by :ref:`set_item_custom_bg_color<class_ItemList_method_set_item_custom_bg_color>`. Default value is ``Color(0, 0, 0, 0)``.
  332. ----
  333. .. _class_ItemList_method_get_item_custom_fg_color:
  334. - :ref:`Color<class_Color>` **get_item_custom_fg_color** **(** :ref:`int<class_int>` idx **)** const
  335. Returns the :ref:`Color<class_Color>` set by :ref:`set_item_custom_fg_color<class_ItemList_method_set_item_custom_fg_color>`. Default value is ``Color(0, 0, 0, 0)``.
  336. ----
  337. .. _class_ItemList_method_get_item_icon:
  338. - :ref:`Texture<class_Texture>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** const
  339. Returns the icon associated with the specified index. Default value is ``null``.
  340. ----
  341. .. _class_ItemList_method_get_item_icon_modulate:
  342. - :ref:`Color<class_Color>` **get_item_icon_modulate** **(** :ref:`int<class_int>` idx **)** const
  343. Returns a :ref:`Color<class_Color>` modulating item's icon at the specified index.
  344. ----
  345. .. _class_ItemList_method_get_item_icon_region:
  346. - :ref:`Rect2<class_Rect2>` **get_item_icon_region** **(** :ref:`int<class_int>` idx **)** const
  347. ----
  348. .. _class_ItemList_method_get_item_metadata:
  349. - :ref:`Variant<class_Variant>` **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
  350. Returns the metadata value of the specified index set by :ref:`set_item_metadata<class_ItemList_method_set_item_metadata>`.
  351. ----
  352. .. _class_ItemList_method_get_item_text:
  353. - :ref:`String<class_String>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
  354. Returns the text associated with the specified index.
  355. ----
  356. .. _class_ItemList_method_get_item_tooltip:
  357. - :ref:`String<class_String>` **get_item_tooltip** **(** :ref:`int<class_int>` idx **)** const
  358. Returns the tooltip hint associated with the specified index.
  359. ----
  360. .. _class_ItemList_method_get_selected_items:
  361. - :ref:`PoolIntArray<class_PoolIntArray>` **get_selected_items** **(** **)**
  362. Returns an array with the indexes of the selected items.
  363. ----
  364. .. _class_ItemList_method_get_v_scroll:
  365. - :ref:`VScrollBar<class_VScrollBar>` **get_v_scroll** **(** **)**
  366. Returns the :ref:`Object<class_Object>` ID associated with the list.
  367. ----
  368. .. _class_ItemList_method_is_anything_selected:
  369. - :ref:`bool<class_bool>` **is_anything_selected** **(** **)**
  370. Returns ``true`` if one or more items are selected.
  371. ----
  372. .. _class_ItemList_method_is_item_disabled:
  373. - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
  374. Returns whether or not the item at the specified index is disabled.
  375. ----
  376. .. _class_ItemList_method_is_item_icon_transposed:
  377. - :ref:`bool<class_bool>` **is_item_icon_transposed** **(** :ref:`int<class_int>` idx **)** const
  378. ----
  379. .. _class_ItemList_method_is_item_selectable:
  380. - :ref:`bool<class_bool>` **is_item_selectable** **(** :ref:`int<class_int>` idx **)** const
  381. Returns whether or not the item at the specified index is selectable.
  382. ----
  383. .. _class_ItemList_method_is_item_tooltip_enabled:
  384. - :ref:`bool<class_bool>` **is_item_tooltip_enabled** **(** :ref:`int<class_int>` idx **)** const
  385. Returns whether the tooltip is enabled for specified item index.
  386. ----
  387. .. _class_ItemList_method_is_selected:
  388. - :ref:`bool<class_bool>` **is_selected** **(** :ref:`int<class_int>` idx **)** const
  389. Returns whether or not item at the specified index is currently selected.
  390. ----
  391. .. _class_ItemList_method_move_item:
  392. - void **move_item** **(** :ref:`int<class_int>` from_idx, :ref:`int<class_int>` to_idx **)**
  393. Moves item from index ``from_idx`` to ``to_idx``.
  394. ----
  395. .. _class_ItemList_method_remove_item:
  396. - void **remove_item** **(** :ref:`int<class_int>` idx **)**
  397. Removes the item specified by ``idx`` index from the list.
  398. ----
  399. .. _class_ItemList_method_select:
  400. - void **select** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` single=true **)**
  401. Select the item at the specified index.
  402. Note: This method does not trigger the item selection signal.
  403. ----
  404. .. _class_ItemList_method_set_item_custom_bg_color:
  405. - void **set_item_custom_bg_color** **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` custom_bg_color **)**
  406. Sets the background color of the item specified by ``idx`` index to the specified :ref:`Color<class_Color>`.
  407. ::
  408. var some_string = "Some text"
  409. some_string.set_item_custom_bg_color(0,Color(1, 0, 0, 1) # This will set the background color of the first item of the control to red.
  410. ----
  411. .. _class_ItemList_method_set_item_custom_fg_color:
  412. - void **set_item_custom_fg_color** **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` custom_fg_color **)**
  413. Sets the foreground color of the item specified by ``idx`` index to the specified :ref:`Color<class_Color>`.
  414. ::
  415. var some_string = "Some text"
  416. some_string.set_item_custom_fg_color(0,Color(1, 0, 0, 1) # This will set the foreground color of the first item of the control to red.
  417. ----
  418. .. _class_ItemList_method_set_item_disabled:
  419. - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  420. Disable (or enable) item at the specified index.
  421. Disabled items are not be selectable and do not trigger activation (Enter or double-click) signals.
  422. ----
  423. .. _class_ItemList_method_set_item_icon:
  424. - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` icon **)**
  425. Set (or replace) the icon's :ref:`Texture<class_Texture>` associated with the specified index.
  426. ----
  427. .. _class_ItemList_method_set_item_icon_modulate:
  428. - void **set_item_icon_modulate** **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` modulate **)**
  429. Sets a modulating :ref:`Color<class_Color>` of the item associated with the specified index.
  430. ----
  431. .. _class_ItemList_method_set_item_icon_region:
  432. - void **set_item_icon_region** **(** :ref:`int<class_int>` idx, :ref:`Rect2<class_Rect2>` rect **)**
  433. ----
  434. .. _class_ItemList_method_set_item_icon_transposed:
  435. - void **set_item_icon_transposed** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` rect **)**
  436. ----
  437. .. _class_ItemList_method_set_item_metadata:
  438. - void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)**
  439. Sets a value (of any type) to be stored with the item associated with the specified index.
  440. ----
  441. .. _class_ItemList_method_set_item_selectable:
  442. - void **set_item_selectable** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` selectable **)**
  443. Allow or disallow selection of the item associated with the specified index.
  444. ----
  445. .. _class_ItemList_method_set_item_text:
  446. - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)**
  447. Sets text of the item associated with the specified index.
  448. ----
  449. .. _class_ItemList_method_set_item_tooltip:
  450. - void **set_item_tooltip** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` tooltip **)**
  451. Sets tooltip hint for the item associated with the specified index.
  452. ----
  453. .. _class_ItemList_method_set_item_tooltip_enabled:
  454. - void **set_item_tooltip_enabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enable **)**
  455. Sets whether the tooltip hint is enabled for specified item index.
  456. ----
  457. .. _class_ItemList_method_sort_items_by_text:
  458. - void **sort_items_by_text** **(** **)**
  459. Sorts items in the list by their text.
  460. ----
  461. .. _class_ItemList_method_unselect:
  462. - void **unselect** **(** :ref:`int<class_int>` idx **)**
  463. Ensure the item associated with the specified index is not selected.
  464. ----
  465. .. _class_ItemList_method_unselect_all:
  466. - void **unselect_all** **(** **)**
  467. Ensure there are no items selected.