class_optionbutton.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. Member Functions
  13. ----------------
  14. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | 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 **)** |
  16. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`add_item<class_OptionButton_add_item>` **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1 **)** |
  18. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`add_separator<class_OptionButton_add_separator>` **(** **)** |
  20. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`clear<class_OptionButton_clear>` **(** **)** |
  22. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`get_item_count<class_OptionButton_get_item_count>` **(** **)** const |
  24. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Texture<class_texture>` | :ref:`get_item_icon<class_OptionButton_get_item_icon>` **(** :ref:`int<class_int>` idx **)** const |
  26. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_item_id<class_OptionButton_get_item_id>` **(** :ref:`int<class_int>` idx **)** const |
  28. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Variant<class_variant>` | :ref:`get_item_metadata<class_OptionButton_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** const |
  30. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`String<class_string>` | :ref:`get_item_text<class_OptionButton_get_item_text>` **(** :ref:`int<class_int>` idx **)** const |
  32. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`int<class_int>` | :ref:`get_selected<class_OptionButton_get_selected>` **(** **)** const |
  34. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`int<class_int>` | :ref:`get_selected_id<class_OptionButton_get_selected_id>` **(** **)** const |
  36. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Variant<class_variant>` | :ref:`get_selected_metadata<class_OptionButton_get_selected_metadata>` **(** **)** const |
  38. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_OptionButton_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** const |
  40. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`remove_item<class_OptionButton_remove_item>` **(** :ref:`int<class_int>` idx **)** |
  42. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`select<class_OptionButton_select>` **(** :ref:`int<class_int>` idx **)** |
  44. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_item_disabled<class_OptionButton_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  46. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`set_item_icon<class_OptionButton_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Texture<class_texture>` texture **)** |
  48. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_item_id<class_OptionButton_set_item_id>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)** |
  50. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`set_item_metadata<class_OptionButton_set_item_metadata>` **(** :ref:`int<class_int>` idx, :ref:`Variant<class_variant>` metadata **)** |
  52. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_item_text<class_OptionButton_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)** |
  54. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. Signals
  56. -------
  57. - **item_selected** **(** :ref:`int<class_int>` ID **)**
  58. 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).
  59. Member Variables
  60. ----------------
  61. - :ref:`Array<class_array>` **items**
  62. - :ref:`int<class_int>` **selected**
  63. Description
  64. -----------
  65. 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.
  66. Member Function Description
  67. ---------------------------
  68. .. _class_OptionButton_add_icon_item:
  69. - void **add_icon_item** **(** :ref:`Texture<class_texture>` texture, :ref:`String<class_string>` label, :ref:`int<class_int>` id **)**
  70. 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.
  71. .. _class_OptionButton_add_item:
  72. - void **add_item** **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1 **)**
  73. 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.
  74. .. _class_OptionButton_add_separator:
  75. - void **add_separator** **(** **)**
  76. 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.
  77. .. _class_OptionButton_clear:
  78. - void **clear** **(** **)**
  79. Clear all the items in the :ref:`OptionButton<class_optionbutton>`.
  80. .. _class_OptionButton_get_item_count:
  81. - :ref:`int<class_int>` **get_item_count** **(** **)** const
  82. Return the amount of items in the OptionButton.
  83. .. _class_OptionButton_get_item_icon:
  84. - :ref:`Texture<class_texture>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** const
  85. Return the icon of the item at index "idx".
  86. .. _class_OptionButton_get_item_id:
  87. - :ref:`int<class_int>` **get_item_id** **(** :ref:`int<class_int>` idx **)** const
  88. Return the ID of the item at index "idx".
  89. .. _class_OptionButton_get_item_metadata:
  90. - :ref:`Variant<class_variant>` **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
  91. .. _class_OptionButton_get_item_text:
  92. - :ref:`String<class_string>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
  93. Return the text of the item at index "idx".
  94. .. _class_OptionButton_get_selected:
  95. - :ref:`int<class_int>` **get_selected** **(** **)** const
  96. Return the current item index
  97. .. _class_OptionButton_get_selected_id:
  98. - :ref:`int<class_int>` **get_selected_id** **(** **)** const
  99. .. _class_OptionButton_get_selected_metadata:
  100. - :ref:`Variant<class_variant>` **get_selected_metadata** **(** **)** const
  101. .. _class_OptionButton_is_item_disabled:
  102. - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
  103. .. _class_OptionButton_remove_item:
  104. - void **remove_item** **(** :ref:`int<class_int>` idx **)**
  105. .. _class_OptionButton_select:
  106. - void **select** **(** :ref:`int<class_int>` idx **)**
  107. Select an item by index and make it the current item.
  108. .. _class_OptionButton_set_item_disabled:
  109. - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  110. .. _class_OptionButton_set_item_icon:
  111. - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_texture>` texture **)**
  112. Set the icon of an item at index "idx".
  113. .. _class_OptionButton_set_item_id:
  114. - void **set_item_id** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)**
  115. Set the ID of an item at index "idx".
  116. .. _class_OptionButton_set_item_metadata:
  117. - void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_variant>` metadata **)**
  118. .. _class_OptionButton_set_item_text:
  119. - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)**
  120. Set the text of an item at index "idx".