OptionButton.xml 11 KB

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