OptionButton.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="OptionButton" inherits="Button" version="3.3">
  3. <brief_description>
  4. Button control that provides selectable options when pressed.
  5. </brief_description>
  6. <description>
  7. 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.
  8. See also [BaseButton] which contains common properties and methods associated with this node.
  9. </description>
  10. <tutorials>
  11. </tutorials>
  12. <methods>
  13. <method name="add_icon_item">
  14. <return type="void" />
  15. <argument index="0" name="texture" type="Texture" />
  16. <argument index="1" name="label" type="String" />
  17. <argument index="2" name="id" type="int" default="-1" />
  18. <description>
  19. Adds an item, with a [code]texture[/code] icon, text [code]label[/code] and (optionally) [code]id[/code]. If no [code]id[/code] is passed, the item index will be used as the item's ID. New items are appended at the end.
  20. </description>
  21. </method>
  22. <method name="add_item">
  23. <return type="void" />
  24. <argument index="0" name="label" type="String" />
  25. <argument index="1" name="id" type="int" default="-1" />
  26. <description>
  27. Adds an item, with text [code]label[/code] and (optionally) [code]id[/code]. If no [code]id[/code] is passed, the item index will be used as the item's ID. New items are appended at the end.
  28. </description>
  29. </method>
  30. <method name="add_separator">
  31. <return type="void" />
  32. <description>
  33. Adds a separator to the list of items. Separators help to group items. Separator also takes up an index and is appended at the end.
  34. </description>
  35. </method>
  36. <method name="clear">
  37. <return type="void" />
  38. <description>
  39. Clears all the items in the [OptionButton].
  40. </description>
  41. </method>
  42. <method name="get_item_count" qualifiers="const">
  43. <return type="int" />
  44. <description>
  45. Returns the amount of items in the OptionButton, including separators.
  46. </description>
  47. </method>
  48. <method name="get_item_icon" qualifiers="const">
  49. <return type="Texture" />
  50. <argument index="0" name="idx" type="int" />
  51. <description>
  52. Returns the icon of the item at index [code]idx[/code].
  53. </description>
  54. </method>
  55. <method name="get_item_id" qualifiers="const">
  56. <return type="int" />
  57. <argument index="0" name="idx" type="int" />
  58. <description>
  59. Returns the ID of the item at index [code]idx[/code].
  60. </description>
  61. </method>
  62. <method name="get_item_index" qualifiers="const">
  63. <return type="int" />
  64. <argument index="0" name="id" type="int" />
  65. <description>
  66. Returns the index of the item with the given [code]id[/code].
  67. </description>
  68. </method>
  69. <method name="get_item_metadata" qualifiers="const">
  70. <return type="Variant" />
  71. <argument index="0" name="idx" type="int" />
  72. <description>
  73. Retrieves the metadata of an item. Metadata may be any type and can be used to store extra information about an item, such as an external string ID.
  74. </description>
  75. </method>
  76. <method name="get_item_text" qualifiers="const">
  77. <return type="String" />
  78. <argument index="0" name="idx" type="int" />
  79. <description>
  80. Returns the text of the item at index [code]idx[/code].
  81. </description>
  82. </method>
  83. <method name="get_popup" qualifiers="const">
  84. <return type="PopupMenu" />
  85. <description>
  86. Returns the [PopupMenu] contained in this button.
  87. </description>
  88. </method>
  89. <method name="get_selected_id" qualifiers="const">
  90. <return type="int" />
  91. <description>
  92. Returns the ID of the selected item, or [code]0[/code] if no item is selected.
  93. </description>
  94. </method>
  95. <method name="get_selected_metadata" qualifiers="const">
  96. <return type="Variant" />
  97. <description>
  98. Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata].
  99. </description>
  100. </method>
  101. <method name="is_item_disabled" qualifiers="const">
  102. <return type="bool" />
  103. <argument index="0" name="idx" type="int" />
  104. <description>
  105. Returns [code]true[/code] if the item at index [code]idx[/code] is disabled.
  106. </description>
  107. </method>
  108. <method name="remove_item">
  109. <return type="void" />
  110. <argument index="0" name="idx" type="int" />
  111. <description>
  112. Removes the item at index [code]idx[/code].
  113. </description>
  114. </method>
  115. <method name="select">
  116. <return type="void" />
  117. <argument index="0" name="idx" type="int" />
  118. <description>
  119. Selects an item by index and makes it the current item. This will work even if the item is disabled.
  120. </description>
  121. </method>
  122. <method name="set_item_disabled">
  123. <return type="void" />
  124. <argument index="0" name="idx" type="int" />
  125. <argument index="1" name="disabled" type="bool" />
  126. <description>
  127. Sets whether the item at index [code]idx[/code] is disabled.
  128. Disabled items are drawn differently in the dropdown and are not selectable by the user. If the current selected item is set as disabled, it will remain selected.
  129. </description>
  130. </method>
  131. <method name="set_item_icon">
  132. <return type="void" />
  133. <argument index="0" name="idx" type="int" />
  134. <argument index="1" name="texture" type="Texture" />
  135. <description>
  136. Sets the icon of the item at index [code]idx[/code].
  137. </description>
  138. </method>
  139. <method name="set_item_id">
  140. <return type="void" />
  141. <argument index="0" name="idx" type="int" />
  142. <argument index="1" name="id" type="int" />
  143. <description>
  144. Sets the ID of the item at index [code]idx[/code].
  145. </description>
  146. </method>
  147. <method name="set_item_metadata">
  148. <return type="void" />
  149. <argument index="0" name="idx" type="int" />
  150. <argument index="1" name="metadata" type="Variant" />
  151. <description>
  152. Sets the metadata of an item. Metadata may be of any type and can be used to store extra information about an item, such as an external string ID.
  153. </description>
  154. </method>
  155. <method name="set_item_text">
  156. <return type="void" />
  157. <argument index="0" name="idx" type="int" />
  158. <argument index="1" name="text" type="String" />
  159. <description>
  160. Sets the text of the item at index [code]idx[/code].
  161. </description>
  162. </method>
  163. </methods>
  164. <members>
  165. <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" override="true" enum="BaseButton.ActionMode" default="0" />
  166. <member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" />
  167. <member name="selected" type="int" setter="_select_int" getter="get_selected" default="-1">
  168. The index of the currently selected item, or [code]-1[/code] if no item is selected.
  169. </member>
  170. <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" />
  171. </members>
  172. <signals>
  173. <signal name="item_focused">
  174. <argument index="0" name="index" type="int" />
  175. <description>
  176. Emitted when the user navigates to an item using the [code]ui_up[/code] or [code]ui_down[/code] actions. The index of the item selected is passed as argument.
  177. </description>
  178. </signal>
  179. <signal name="item_selected">
  180. <argument index="0" name="index" type="int" />
  181. <description>
  182. Emitted when the current item has been changed by the user. The index of the item selected is passed as argument.
  183. </description>
  184. </signal>
  185. </signals>
  186. <constants>
  187. </constants>
  188. <theme_items>
  189. <theme_item name="arrow" type="Texture">
  190. The arrow icon to be drawn on the right end of the button.
  191. </theme_item>
  192. <theme_item name="arrow_margin" type="int" default="2">
  193. The horizontal space between the arrow icon and the right edge of the button.
  194. </theme_item>
  195. <theme_item name="disabled" type="StyleBox">
  196. [StyleBox] used when the [OptionButton] is disabled.
  197. </theme_item>
  198. <theme_item name="focus" type="StyleBox">
  199. [StyleBox] used when the [OptionButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect.
  200. </theme_item>
  201. <theme_item name="font" type="Font">
  202. [Font] of the [OptionButton]'s text.
  203. </theme_item>
  204. <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
  205. Default text [Color] of the [OptionButton].
  206. </theme_item>
  207. <theme_item name="font_color_disabled" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
  208. Text [Color] used when the [OptionButton] is disabled.
  209. </theme_item>
  210. <theme_item name="font_color_hover" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
  211. Text [Color] used when the [OptionButton] is being hovered.
  212. </theme_item>
  213. <theme_item name="font_color_pressed" type="Color" default="Color( 1, 1, 1, 1 )">
  214. Text [Color] used when the [OptionButton] is being pressed.
  215. </theme_item>
  216. <theme_item name="hover" type="StyleBox">
  217. [StyleBox] used when the [OptionButton] is being hovered.
  218. </theme_item>
  219. <theme_item name="hseparation" type="int" default="2">
  220. The horizontal space between [OptionButton]'s icon and text.
  221. </theme_item>
  222. <theme_item name="normal" type="StyleBox">
  223. Default [StyleBox] for the [OptionButton].
  224. </theme_item>
  225. <theme_item name="pressed" type="StyleBox">
  226. [StyleBox] used when the [OptionButton] is being pressed.
  227. </theme_item>
  228. </theme_items>
  229. </class>