class_optionbutton.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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_item<class_OptionButton_add_item>` **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1 **)** |
  15. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | 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 **)** |
  17. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`set_item_text<class_OptionButton_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)** |
  19. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`set_item_icon<class_OptionButton_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Texture<class_texture>` texture **)** |
  21. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`set_item_disabled<class_OptionButton_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
  23. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`set_item_ID<class_OptionButton_set_item_ID>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)** |
  25. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`set_item_metadata<class_OptionButton_set_item_metadata>` **(** :ref:`int<class_int>` idx, var metadata **)** |
  27. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`String<class_string>` | :ref:`get_item_text<class_OptionButton_get_item_text>` **(** :ref:`int<class_int>` idx **)** 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. | void | :ref:`get_item_metadata<class_OptionButton_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** const |
  35. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_OptionButton_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** const |
  37. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_item_count<class_OptionButton_get_item_count>` **(** **)** const |
  39. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`add_separator<class_OptionButton_add_separator>` **(** **)** |
  41. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`clear<class_OptionButton_clear>` **(** **)** |
  43. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`select<class_OptionButton_select>` **(** :ref:`int<class_int>` idx **)** |
  45. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`get_selected<class_OptionButton_get_selected>` **(** **)** const |
  47. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`get_selected_ID<class_OptionButton_get_selected_ID>` **(** **)** const |
  49. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`get_selected_metadata<class_OptionButton_get_selected_metadata>` **(** **)** const |
  51. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`remove_item<class_OptionButton_remove_item>` **(** :ref:`int<class_int>` idx **)** |
  53. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. Signals
  55. -------
  56. - **item_selected** **(** :ref:`int<class_int>` ID **)**
  57. Description
  58. -----------
  59. 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.
  60. Member Function Description
  61. ---------------------------
  62. .. _class_OptionButton_add_item:
  63. - void **add_item** **(** :ref:`String<class_string>` label, :ref:`int<class_int>` id=-1 **)**
  64. 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.
  65. .. _class_OptionButton_add_icon_item:
  66. - void **add_icon_item** **(** :ref:`Texture<class_texture>` texture, :ref:`String<class_string>` label, :ref:`int<class_int>` id **)**
  67. 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.
  68. .. _class_OptionButton_set_item_text:
  69. - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_string>` text **)**
  70. Set the text of an item at index "idx".
  71. .. _class_OptionButton_set_item_icon:
  72. - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_texture>` texture **)**
  73. Set the icon of an item at index "idx".
  74. .. _class_OptionButton_set_item_disabled:
  75. - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
  76. .. _class_OptionButton_set_item_ID:
  77. - void **set_item_ID** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)**
  78. Set the ID of an item at index "idx".
  79. .. _class_OptionButton_set_item_metadata:
  80. - void **set_item_metadata** **(** :ref:`int<class_int>` idx, var metadata **)**
  81. .. _class_OptionButton_get_item_text:
  82. - :ref:`String<class_string>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
  83. Return the text of the item at index "idx".
  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. - void **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
  92. .. _class_OptionButton_is_item_disabled:
  93. - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
  94. .. _class_OptionButton_get_item_count:
  95. - :ref:`int<class_int>` **get_item_count** **(** **)** const
  96. Return the amount of items in the OptionButton.
  97. .. _class_OptionButton_add_separator:
  98. - void **add_separator** **(** **)**
  99. 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.
  100. .. _class_OptionButton_clear:
  101. - void **clear** **(** **)**
  102. Clear all the items in the :ref:`OptionButton<class_optionbutton>`.
  103. .. _class_OptionButton_select:
  104. - void **select** **(** :ref:`int<class_int>` idx **)**
  105. Select an item by index and make it the current item.
  106. .. _class_OptionButton_get_selected:
  107. - :ref:`int<class_int>` **get_selected** **(** **)** const
  108. Return the current item index
  109. .. _class_OptionButton_get_selected_ID:
  110. - :ref:`int<class_int>` **get_selected_ID** **(** **)** const
  111. .. _class_OptionButton_get_selected_metadata:
  112. - void **get_selected_metadata** **(** **)** const
  113. .. _class_OptionButton_remove_item:
  114. - void **remove_item** **(** :ref:`int<class_int>` idx **)**