class_optionbutton.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the OptionButton.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_OptionButton:
  5. OptionButton
  6. ============
  7. **Inherits:** :ref:`Button<class_Button>` **<** :ref:`BaseButton<class_BaseButton>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Button control that provides selectable options when pressed.
  12. Properties
  13. ----------
  14. +-----------------------+----------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`selected<class_OptionButton_selected>` |
  16. +-----------------------+----------------------------------------------+
  17. Methods
  18. -------
  19. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`add_icon_item<class_OptionButton_add_icon_item>` **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1 **)** |
  21. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`add_item<class_OptionButton_add_item>` **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1 **)** |
  23. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`add_separator<class_OptionButton_add_separator>` **(** **)** |
  25. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`clear<class_OptionButton_clear>` **(** **)** |
  27. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`int<class_int>` | :ref:`get_item_count<class_OptionButton_get_item_count>` **(** **)** const |
  29. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Texture<class_Texture>` | :ref:`get_item_icon<class_OptionButton_get_item_icon>` **(** :ref:`int<class_int>` idx **)** const |
  31. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`get_item_id<class_OptionButton_get_item_id>` **(** :ref:`int<class_int>` idx **)** const |
  33. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Variant<class_Variant>` | :ref:`get_item_metadata<class_OptionButton_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** const |
  35. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`String<class_String>` | :ref:`get_item_text<class_OptionButton_get_item_text>` **(** :ref:`int<class_int>` idx **)** const |
  37. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`PopupMenu<class_PopupMenu>` | :ref:`get_popup<class_OptionButton_get_popup>` **(** **)** const |
  39. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`get_selected_id<class_OptionButton_get_selected_id>` **(** **)** const |
  41. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Variant<class_Variant>` | :ref:`get_selected_metadata<class_OptionButton_get_selected_metadata>` **(** **)** const |
  43. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_OptionButton_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** const |
  45. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`remove_item<class_OptionButton_remove_item>` **(** :ref:`int<class_int>` idx **)** |
  47. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`select<class_OptionButton_select>` **(** :ref:`int<class_int>` idx **)** |
  49. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_item_disabled<class_OptionButton_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  51. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_item_icon<class_OptionButton_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` texture **)** |
  53. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_item_id<class_OptionButton_set_item_id>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)** |
  55. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_item_metadata<class_OptionButton_set_item_metadata>` **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)** |
  57. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_item_text<class_OptionButton_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)** |
  59. +------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. Theme Properties
  61. ----------------
  62. +---------------------------------+--------------------------------------------------------------------+
  63. | :ref:`Texture<class_Texture>` | :ref:`arrow<class_OptionButton_arrow>` |
  64. +---------------------------------+--------------------------------------------------------------------+
  65. | :ref:`int<class_int>` | :ref:`arrow_margin<class_OptionButton_arrow_margin>` |
  66. +---------------------------------+--------------------------------------------------------------------+
  67. | :ref:`StyleBox<class_StyleBox>` | :ref:`disabled<class_OptionButton_disabled>` |
  68. +---------------------------------+--------------------------------------------------------------------+
  69. | :ref:`StyleBox<class_StyleBox>` | :ref:`focus<class_OptionButton_focus>` |
  70. +---------------------------------+--------------------------------------------------------------------+
  71. | :ref:`Font<class_Font>` | :ref:`font<class_OptionButton_font>` |
  72. +---------------------------------+--------------------------------------------------------------------+
  73. | :ref:`Color<class_Color>` | :ref:`font_color<class_OptionButton_font_color>` |
  74. +---------------------------------+--------------------------------------------------------------------+
  75. | :ref:`Color<class_Color>` | :ref:`font_color_disabled<class_OptionButton_font_color_disabled>` |
  76. +---------------------------------+--------------------------------------------------------------------+
  77. | :ref:`Color<class_Color>` | :ref:`font_color_hover<class_OptionButton_font_color_hover>` |
  78. +---------------------------------+--------------------------------------------------------------------+
  79. | :ref:`Color<class_Color>` | :ref:`font_color_pressed<class_OptionButton_font_color_pressed>` |
  80. +---------------------------------+--------------------------------------------------------------------+
  81. | :ref:`StyleBox<class_StyleBox>` | :ref:`hover<class_OptionButton_hover>` |
  82. +---------------------------------+--------------------------------------------------------------------+
  83. | :ref:`int<class_int>` | :ref:`hseparation<class_OptionButton_hseparation>` |
  84. +---------------------------------+--------------------------------------------------------------------+
  85. | :ref:`StyleBox<class_StyleBox>` | :ref:`normal<class_OptionButton_normal>` |
  86. +---------------------------------+--------------------------------------------------------------------+
  87. | :ref:`StyleBox<class_StyleBox>` | :ref:`pressed<class_OptionButton_pressed>` |
  88. +---------------------------------+--------------------------------------------------------------------+
  89. Signals
  90. -------
  91. .. _class_OptionButton_item_focused:
  92. - **item_focused** **(** :ref:`int<class_int>` ID **)**
  93. This signal is emitted when user navigated to an item using ``ui_up`` or ``ui_down`` action. ID of the item selected is passed as argument (if no IDs were added, ID will be just the item index).
  94. .. _class_OptionButton_item_selected:
  95. - **item_selected** **(** :ref:`int<class_int>` ID **)**
  96. This signal is emitted when the current item was changed by the user. ID of the item selected is passed as argument (if no IDs were added, ID will be just the item index).
  97. Description
  98. -----------
  99. OptionButton is a type button that provides a selectable list of items when pressed. The item selected becomes the "current" item and is displayed as the button text.
  100. Property Descriptions
  101. ---------------------
  102. .. _class_OptionButton_selected:
  103. - :ref:`int<class_int>` **selected**
  104. +----------+----------------+
  105. | *Getter* | get_selected() |
  106. +----------+----------------+
  107. Method Descriptions
  108. -------------------
  109. .. _class_OptionButton_add_icon_item:
  110. - void **add_icon_item** **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1 **)**
  111. Add an item, with a "texture" icon, text "label" and (optionally) id. If no "id" is passed, "id" becomes the item index. New items are appended at the end.
  112. .. _class_OptionButton_add_item:
  113. - void **add_item** **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1 **)**
  114. Add an item, with text "label" and (optionally) id. If no "id" is passed, "id" becomes the item index. New items are appended at the end.
  115. .. _class_OptionButton_add_separator:
  116. - void **add_separator** **(** **)**
  117. Add a separator to the list of items. Separators help to group items. Separator also takes up an index and is appended at the end.
  118. .. _class_OptionButton_clear:
  119. - void **clear** **(** **)**
  120. Clear all the items in the ``OptionButton``.
  121. .. _class_OptionButton_get_item_count:
  122. - :ref:`int<class_int>` **get_item_count** **(** **)** const
  123. Return the amount of items in the OptionButton.
  124. .. _class_OptionButton_get_item_icon:
  125. - :ref:`Texture<class_Texture>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** const
  126. Return the icon of the item at index "idx".
  127. .. _class_OptionButton_get_item_id:
  128. - :ref:`int<class_int>` **get_item_id** **(** :ref:`int<class_int>` idx **)** const
  129. Return the ID of the item at index "idx".
  130. .. _class_OptionButton_get_item_metadata:
  131. - :ref:`Variant<class_Variant>` **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
  132. .. _class_OptionButton_get_item_text:
  133. - :ref:`String<class_String>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
  134. Return the text of the item at index "idx".
  135. .. _class_OptionButton_get_popup:
  136. - :ref:`PopupMenu<class_PopupMenu>` **get_popup** **(** **)** const
  137. Return the :ref:`PopupMenu<class_PopupMenu>` contained in this button.
  138. .. _class_OptionButton_get_selected_id:
  139. - :ref:`int<class_int>` **get_selected_id** **(** **)** const
  140. .. _class_OptionButton_get_selected_metadata:
  141. - :ref:`Variant<class_Variant>` **get_selected_metadata** **(** **)** const
  142. .. _class_OptionButton_is_item_disabled:
  143. - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
  144. .. _class_OptionButton_remove_item:
  145. - void **remove_item** **(** :ref:`int<class_int>` idx **)**
  146. .. _class_OptionButton_select:
  147. - void **select** **(** :ref:`int<class_int>` idx **)**
  148. Select an item by index and make it the current item.
  149. .. _class_OptionButton_set_item_disabled:
  150. - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  151. .. _class_OptionButton_set_item_icon:
  152. - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` texture **)**
  153. Set the icon of an item at index "idx".
  154. .. _class_OptionButton_set_item_id:
  155. - void **set_item_id** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)**
  156. Set the ID of an item at index "idx".
  157. .. _class_OptionButton_set_item_metadata:
  158. - void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)**
  159. .. _class_OptionButton_set_item_text:
  160. - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)**
  161. Set the text of an item at index "idx".