OptionButton.xml 9.6 KB

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