class_optionbutton.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_OptionButton:
  4. OptionButton
  5. ============
  6. **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>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Button control that provides selectable options when pressed.
  11. Member Functions
  12. ----------------
  13. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | 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 **)** |
  15. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`add_item<class_OptionButton_add_item>` **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1 **)** |
  17. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`add_separator<class_OptionButton_add_separator>` **(** **)** |
  19. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`clear<class_OptionButton_clear>` **(** **)** |
  21. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`int<class_int>` | :ref:`get_item_ID<class_OptionButton_get_item_ID>` **(** :ref:`int<class_int>` idx **)** const |
  23. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`get_item_count<class_OptionButton_get_item_count>` **(** **)** const |
  25. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Texture<class_texture>` | :ref:`get_item_icon<class_OptionButton_get_item_icon>` **(** :ref:`int<class_int>` idx **)** const |
  27. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`get_item_metadata<class_OptionButton_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** const |
  29. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`String<class_string>` | :ref:`get_item_text<class_OptionButton_get_item_text>` **(** :ref:`int<class_int>` idx **)** const |
  31. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`get_selected<class_OptionButton_get_selected>` **(** **)** const |
  33. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_selected_ID<class_OptionButton_get_selected_ID>` **(** **)** const |
  35. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`get_selected_metadata<class_OptionButton_get_selected_metadata>` **(** **)** const |
  37. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_OptionButton_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** const |
  39. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`remove_item<class_OptionButton_remove_item>` **(** :ref:`int<class_int>` idx **)** |
  41. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`select<class_OptionButton_select>` **(** :ref:`int<class_int>` idx **)** |
  43. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_item_ID<class_OptionButton_set_item_ID>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)** |
  45. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_item_disabled<class_OptionButton_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  47. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_item_icon<class_OptionButton_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Texture<class_texture>` texture **)** |
  49. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_item_metadata<class_OptionButton_set_item_metadata>` **(** :ref:`int<class_int>` idx, :ref:`Variant<class_variant>` metadata **)** |
  51. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_item_text<class_OptionButton_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)** |
  53. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. Signals
  55. -------
  56. - **item_selected** **(** :ref:`int<class_int>` ID **)**
  57. 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).
  58. Description
  59. -----------
  60. 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.
  61. Member Function Description
  62. ---------------------------
  63. .. _class_OptionButton_add_icon_item:
  64. - void **add_icon_item** **(** :ref:`Texture<class_texture>` texture, :ref:`String<class_string>` label, :ref:`int<class_int>` id **)**
  65. 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.
  66. .. _class_OptionButton_add_item:
  67. - void **add_item** **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1 **)**
  68. 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.
  69. .. _class_OptionButton_add_separator:
  70. - void **add_separator** **(** **)**
  71. 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.
  72. .. _class_OptionButton_clear:
  73. - void **clear** **(** **)**
  74. Clear all the items in the :ref:`OptionButton<class_optionbutton>`.
  75. .. _class_OptionButton_get_item_ID:
  76. - :ref:`int<class_int>` **get_item_ID** **(** :ref:`int<class_int>` idx **)** const
  77. Return the ID of the item at index "idx".
  78. .. _class_OptionButton_get_item_count:
  79. - :ref:`int<class_int>` **get_item_count** **(** **)** const
  80. Return the amount of items in the OptionButton.
  81. .. _class_OptionButton_get_item_icon:
  82. - :ref:`Texture<class_texture>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** const
  83. Return the icon of the item at index "idx".
  84. .. _class_OptionButton_get_item_metadata:
  85. - void **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
  86. .. _class_OptionButton_get_item_text:
  87. - :ref:`String<class_string>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
  88. Return the text of the item at index "idx".
  89. .. _class_OptionButton_get_selected:
  90. - :ref:`int<class_int>` **get_selected** **(** **)** const
  91. Return the current item index
  92. .. _class_OptionButton_get_selected_ID:
  93. - :ref:`int<class_int>` **get_selected_ID** **(** **)** const
  94. .. _class_OptionButton_get_selected_metadata:
  95. - void **get_selected_metadata** **(** **)** const
  96. .. _class_OptionButton_is_item_disabled:
  97. - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
  98. .. _class_OptionButton_remove_item:
  99. - void **remove_item** **(** :ref:`int<class_int>` idx **)**
  100. .. _class_OptionButton_select:
  101. - void **select** **(** :ref:`int<class_int>` idx **)**
  102. Select an item by index and make it the current item.
  103. .. _class_OptionButton_set_item_ID:
  104. - void **set_item_ID** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)**
  105. Set the ID of an item at index "idx".
  106. .. _class_OptionButton_set_item_disabled:
  107. - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  108. .. _class_OptionButton_set_item_icon:
  109. - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_texture>` texture **)**
  110. Set the icon of an item at index "idx".
  111. .. _class_OptionButton_set_item_metadata:
  112. - void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_variant>` metadata **)**
  113. .. _class_OptionButton_set_item_text:
  114. - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)**
  115. Set the text of an item at index "idx".