class_optionbutton.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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:`PopupMenu<class_popupmenu>` | :ref:`get_popup<class_OptionButton_get_popup>` **(** **)** 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. .. _class_OptionButton_item_selected:
  58. - **item_selected** **(** :ref:`int<class_int>` ID **)**
  59. 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).
  60. Member Variables
  61. ----------------
  62. .. _class_OptionButton_selected:
  63. - :ref:`int<class_int>` **selected**
  64. Description
  65. -----------
  66. 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.
  67. Member Function Description
  68. ---------------------------
  69. .. _class_OptionButton_add_icon_item:
  70. - void **add_icon_item** **(** :ref:`Texture<class_texture>` texture, :ref:`String<class_string>` label, :ref:`int<class_int>` id **)**
  71. 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.
  72. .. _class_OptionButton_add_item:
  73. - void **add_item** **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1 **)**
  74. 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.
  75. .. _class_OptionButton_add_separator:
  76. - void **add_separator** **(** **)**
  77. 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.
  78. .. _class_OptionButton_clear:
  79. - void **clear** **(** **)**
  80. Clear all the items in the ``OptionButton``.
  81. .. _class_OptionButton_get_item_count:
  82. - :ref:`int<class_int>` **get_item_count** **(** **)** const
  83. Return the amount of items in the OptionButton.
  84. .. _class_OptionButton_get_item_icon:
  85. - :ref:`Texture<class_texture>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** const
  86. Return the icon of the item at index "idx".
  87. .. _class_OptionButton_get_item_id:
  88. - :ref:`int<class_int>` **get_item_id** **(** :ref:`int<class_int>` idx **)** const
  89. Return the ID of the item at index "idx".
  90. .. _class_OptionButton_get_item_metadata:
  91. - :ref:`Variant<class_variant>` **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
  92. .. _class_OptionButton_get_item_text:
  93. - :ref:`String<class_string>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
  94. Return the text of the item at index "idx".
  95. .. _class_OptionButton_get_popup:
  96. - :ref:`PopupMenu<class_popupmenu>` **get_popup** **(** **)** const
  97. Return the :ref:`PopupMenu<class_popupmenu>` contained in this button.
  98. .. _class_OptionButton_get_selected_id:
  99. - :ref:`int<class_int>` **get_selected_id** **(** **)** const
  100. .. _class_OptionButton_get_selected_metadata:
  101. - :ref:`Variant<class_variant>` **get_selected_metadata** **(** **)** const
  102. .. _class_OptionButton_is_item_disabled:
  103. - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
  104. .. _class_OptionButton_remove_item:
  105. - void **remove_item** **(** :ref:`int<class_int>` idx **)**
  106. .. _class_OptionButton_select:
  107. - void **select** **(** :ref:`int<class_int>` idx **)**
  108. Select an item by index and make it the current item.
  109. .. _class_OptionButton_set_item_disabled:
  110. - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  111. .. _class_OptionButton_set_item_icon:
  112. - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_texture>` texture **)**
  113. Set the icon of an item at index "idx".
  114. .. _class_OptionButton_set_item_id:
  115. - void **set_item_id** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)**
  116. Set the ID of an item at index "idx".
  117. .. _class_OptionButton_set_item_metadata:
  118. - void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_variant>` metadata **)**
  119. .. _class_OptionButton_set_item_text:
  120. - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)**
  121. Set the text of an item at index "idx".