OptionButton.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. </return>
  16. <argument index="0" name="texture" type="Texture">
  17. </argument>
  18. <argument index="1" name="label" type="String">
  19. </argument>
  20. <argument index="2" name="id" type="int" default="-1">
  21. </argument>
  22. <description>
  23. 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.
  24. </description>
  25. </method>
  26. <method name="add_item">
  27. <return type="void">
  28. </return>
  29. <argument index="0" name="label" type="String">
  30. </argument>
  31. <argument index="1" name="id" type="int" default="-1">
  32. </argument>
  33. <description>
  34. 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.
  35. </description>
  36. </method>
  37. <method name="add_separator">
  38. <return type="void">
  39. </return>
  40. <description>
  41. 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.
  42. </description>
  43. </method>
  44. <method name="clear">
  45. <return type="void">
  46. </return>
  47. <description>
  48. Clears all the items in the [OptionButton].
  49. </description>
  50. </method>
  51. <method name="get_item_count" qualifiers="const">
  52. <return type="int">
  53. </return>
  54. <description>
  55. Returns the amount of items in the OptionButton, including separators.
  56. </description>
  57. </method>
  58. <method name="get_item_icon" qualifiers="const">
  59. <return type="Texture">
  60. </return>
  61. <argument index="0" name="idx" type="int">
  62. </argument>
  63. <description>
  64. Returns the icon of the item at index [code]idx[/code].
  65. </description>
  66. </method>
  67. <method name="get_item_id" qualifiers="const">
  68. <return type="int">
  69. </return>
  70. <argument index="0" name="idx" type="int">
  71. </argument>
  72. <description>
  73. Returns the ID of the item at index [code]idx[/code].
  74. </description>
  75. </method>
  76. <method name="get_item_index" qualifiers="const">
  77. <return type="int">
  78. </return>
  79. <argument index="0" name="id" type="int">
  80. </argument>
  81. <description>
  82. Returns the index of the item with the given [code]id[/code].
  83. </description>
  84. </method>
  85. <method name="get_item_metadata" qualifiers="const">
  86. <return type="Variant">
  87. </return>
  88. <argument index="0" name="idx" type="int">
  89. </argument>
  90. <description>
  91. 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.
  92. </description>
  93. </method>
  94. <method name="get_item_text" qualifiers="const">
  95. <return type="String">
  96. </return>
  97. <argument index="0" name="idx" type="int">
  98. </argument>
  99. <description>
  100. Returns the text of the item at index [code]idx[/code].
  101. </description>
  102. </method>
  103. <method name="get_popup" qualifiers="const">
  104. <return type="PopupMenu">
  105. </return>
  106. <description>
  107. Returns the [PopupMenu] contained in this button.
  108. </description>
  109. </method>
  110. <method name="get_selected_id" qualifiers="const">
  111. <return type="int">
  112. </return>
  113. <description>
  114. Returns the ID of the selected item, or [code]0[/code] if no item is selected.
  115. </description>
  116. </method>
  117. <method name="get_selected_metadata" qualifiers="const">
  118. <return type="Variant">
  119. </return>
  120. <description>
  121. Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata].
  122. </description>
  123. </method>
  124. <method name="is_item_disabled" qualifiers="const">
  125. <return type="bool">
  126. </return>
  127. <argument index="0" name="idx" type="int">
  128. </argument>
  129. <description>
  130. Returns [code]true[/code] if the item at index [code]idx[/code] is disabled.
  131. </description>
  132. </method>
  133. <method name="remove_item">
  134. <return type="void">
  135. </return>
  136. <argument index="0" name="idx" type="int">
  137. </argument>
  138. <description>
  139. Removes the item at index [code]idx[/code].
  140. </description>
  141. </method>
  142. <method name="select">
  143. <return type="void">
  144. </return>
  145. <argument index="0" name="idx" type="int">
  146. </argument>
  147. <description>
  148. Selects an item by index and makes it the current item. This will work even if the item is disabled.
  149. </description>
  150. </method>
  151. <method name="set_item_disabled">
  152. <return type="void">
  153. </return>
  154. <argument index="0" name="idx" type="int">
  155. </argument>
  156. <argument index="1" name="disabled" type="bool">
  157. </argument>
  158. <description>
  159. Sets whether the item at index [code]idx[/code] is disabled.
  160. 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.
  161. </description>
  162. </method>
  163. <method name="set_item_icon">
  164. <return type="void">
  165. </return>
  166. <argument index="0" name="idx" type="int">
  167. </argument>
  168. <argument index="1" name="texture" type="Texture">
  169. </argument>
  170. <description>
  171. Sets the icon of the item at index [code]idx[/code].
  172. </description>
  173. </method>
  174. <method name="set_item_id">
  175. <return type="void">
  176. </return>
  177. <argument index="0" name="idx" type="int">
  178. </argument>
  179. <argument index="1" name="id" type="int">
  180. </argument>
  181. <description>
  182. Sets the ID of the item at index [code]idx[/code].
  183. </description>
  184. </method>
  185. <method name="set_item_metadata">
  186. <return type="void">
  187. </return>
  188. <argument index="0" name="idx" type="int">
  189. </argument>
  190. <argument index="1" name="metadata" type="Variant">
  191. </argument>
  192. <description>
  193. 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.
  194. </description>
  195. </method>
  196. <method name="set_item_text">
  197. <return type="void">
  198. </return>
  199. <argument index="0" name="idx" type="int">
  200. </argument>
  201. <argument index="1" name="text" type="String">
  202. </argument>
  203. <description>
  204. Sets the text of the item at index [code]idx[/code].
  205. </description>
  206. </method>
  207. </methods>
  208. <members>
  209. <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" override="true" enum="BaseButton.ActionMode" default="0" />
  210. <member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" />
  211. <member name="selected" type="int" setter="_select_int" getter="get_selected" default="-1">
  212. The index of the currently selected item, or [code]-1[/code] if no item is selected.
  213. </member>
  214. <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" />
  215. </members>
  216. <signals>
  217. <signal name="item_focused">
  218. <argument index="0" name="index" type="int">
  219. </argument>
  220. <description>
  221. 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.
  222. </description>
  223. </signal>
  224. <signal name="item_selected">
  225. <argument index="0" name="index" type="int">
  226. </argument>
  227. <description>
  228. Emitted when the current item has been changed by the user. The index of the item selected is passed as argument.
  229. </description>
  230. </signal>
  231. </signals>
  232. <constants>
  233. </constants>
  234. <theme_items>
  235. <theme_item name="arrow" type="Texture">
  236. The arrow icon to be drawn on the right end of the button.
  237. </theme_item>
  238. <theme_item name="arrow_margin" type="int" default="2">
  239. The horizontal space between the arrow icon and the right edge of the button.
  240. </theme_item>
  241. <theme_item name="disabled" type="StyleBox">
  242. [StyleBox] used when the [OptionButton] is disabled.
  243. </theme_item>
  244. <theme_item name="focus" type="StyleBox">
  245. [StyleBox] used when the [OptionButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect.
  246. </theme_item>
  247. <theme_item name="font" type="Font">
  248. [Font] of the [OptionButton]'s text.
  249. </theme_item>
  250. <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
  251. Default text [Color] of the [OptionButton].
  252. </theme_item>
  253. <theme_item name="font_color_disabled" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
  254. Text [Color] used when the [OptionButton] is disabled.
  255. </theme_item>
  256. <theme_item name="font_color_hover" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
  257. Text [Color] used when the [OptionButton] is being hovered.
  258. </theme_item>
  259. <theme_item name="font_color_pressed" type="Color" default="Color( 1, 1, 1, 1 )">
  260. Text [Color] used when the [OptionButton] is being pressed.
  261. </theme_item>
  262. <theme_item name="hover" type="StyleBox">
  263. [StyleBox] used when the [OptionButton] is being hovered.
  264. </theme_item>
  265. <theme_item name="hseparation" type="int" default="2">
  266. The horizontal space between [OptionButton]'s icon and text.
  267. </theme_item>
  268. <theme_item name="normal" type="StyleBox">
  269. Default [StyleBox] for the [OptionButton].
  270. </theme_item>
  271. <theme_item name="pressed" type="StyleBox">
  272. [StyleBox] used when the [OptionButton] is being pressed.
  273. </theme_item>
  274. </theme_items>
  275. </class>