OptionButton.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="OptionButton" inherits="Button" version="3.4">
  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. [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.
  88. </description>
  89. </method>
  90. <method name="get_selected_id" qualifiers="const">
  91. <return type="int" />
  92. <description>
  93. Returns the ID of the selected item, or [code]0[/code] if no item is selected.
  94. </description>
  95. </method>
  96. <method name="get_selected_metadata" qualifiers="const">
  97. <return type="Variant" />
  98. <description>
  99. Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata].
  100. </description>
  101. </method>
  102. <method name="is_item_disabled" qualifiers="const">
  103. <return type="bool" />
  104. <argument index="0" name="idx" type="int" />
  105. <description>
  106. Returns [code]true[/code] if the item at index [code]idx[/code] is disabled.
  107. </description>
  108. </method>
  109. <method name="remove_item">
  110. <return type="void" />
  111. <argument index="0" name="idx" type="int" />
  112. <description>
  113. Removes the item at index [code]idx[/code].
  114. </description>
  115. </method>
  116. <method name="select">
  117. <return type="void" />
  118. <argument index="0" name="idx" type="int" />
  119. <description>
  120. Selects an item by index and makes it the current item. This will work even if the item is disabled.
  121. </description>
  122. </method>
  123. <method name="set_item_disabled">
  124. <return type="void" />
  125. <argument index="0" name="idx" type="int" />
  126. <argument index="1" name="disabled" type="bool" />
  127. <description>
  128. Sets whether the item at index [code]idx[/code] is disabled.
  129. 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.
  130. </description>
  131. </method>
  132. <method name="set_item_icon">
  133. <return type="void" />
  134. <argument index="0" name="idx" type="int" />
  135. <argument index="1" name="texture" type="Texture" />
  136. <description>
  137. Sets the icon of the item at index [code]idx[/code].
  138. </description>
  139. </method>
  140. <method name="set_item_id">
  141. <return type="void" />
  142. <argument index="0" name="idx" type="int" />
  143. <argument index="1" name="id" type="int" />
  144. <description>
  145. Sets the ID of the item at index [code]idx[/code].
  146. </description>
  147. </method>
  148. <method name="set_item_metadata">
  149. <return type="void" />
  150. <argument index="0" name="idx" type="int" />
  151. <argument index="1" name="metadata" type="Variant" />
  152. <description>
  153. 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.
  154. </description>
  155. </method>
  156. <method name="set_item_text">
  157. <return type="void" />
  158. <argument index="0" name="idx" type="int" />
  159. <argument index="1" name="text" type="String" />
  160. <description>
  161. Sets the text of the item at index [code]idx[/code].
  162. </description>
  163. </method>
  164. </methods>
  165. <members>
  166. <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" override="true" enum="BaseButton.ActionMode" default="0" />
  167. <member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" />
  168. <member name="selected" type="int" setter="_select_int" getter="get_selected" default="-1">
  169. The index of the currently selected item, or [code]-1[/code] if no item is selected.
  170. </member>
  171. <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" />
  172. </members>
  173. <signals>
  174. <signal name="item_focused">
  175. <argument index="0" name="index" type="int" />
  176. <description>
  177. 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.
  178. </description>
  179. </signal>
  180. <signal name="item_selected">
  181. <argument index="0" name="index" type="int" />
  182. <description>
  183. Emitted when the current item has been changed by the user. The index of the item selected is passed as argument.
  184. </description>
  185. </signal>
  186. </signals>
  187. <constants>
  188. </constants>
  189. <theme_items>
  190. <theme_item name="arrow" data_type="icon" type="Texture">
  191. The arrow icon to be drawn on the right end of the button.
  192. </theme_item>
  193. <theme_item name="arrow_margin" data_type="constant" type="int" default="2">
  194. The horizontal space between the arrow icon and the right edge of the button.
  195. </theme_item>
  196. <theme_item name="disabled" data_type="style" type="StyleBox">
  197. [StyleBox] used when the [OptionButton] is disabled.
  198. </theme_item>
  199. <theme_item name="focus" data_type="style" type="StyleBox">
  200. [StyleBox] used when the [OptionButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect.
  201. </theme_item>
  202. <theme_item name="font" data_type="font" type="Font">
  203. [Font] of the [OptionButton]'s text.
  204. </theme_item>
  205. <theme_item name="font_color" data_type="color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
  206. Default text [Color] of the [OptionButton].
  207. </theme_item>
  208. <theme_item name="font_color_disabled" data_type="color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
  209. Text [Color] used when the [OptionButton] is disabled.
  210. </theme_item>
  211. <theme_item name="font_color_focus" data_type="color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
  212. 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.
  213. </theme_item>
  214. <theme_item name="font_color_hover" data_type="color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
  215. Text [Color] used when the [OptionButton] is being hovered.
  216. </theme_item>
  217. <theme_item name="font_color_pressed" data_type="color" type="Color" default="Color( 1, 1, 1, 1 )">
  218. Text [Color] used when the [OptionButton] is being pressed.
  219. </theme_item>
  220. <theme_item name="hover" data_type="style" type="StyleBox">
  221. [StyleBox] used when the [OptionButton] is being hovered.
  222. </theme_item>
  223. <theme_item name="hseparation" data_type="constant" type="int" default="2">
  224. The horizontal space between [OptionButton]'s icon and text.
  225. </theme_item>
  226. <theme_item name="normal" data_type="style" type="StyleBox">
  227. Default [StyleBox] for the [OptionButton].
  228. </theme_item>
  229. <theme_item name="pressed" data_type="style" type="StyleBox">
  230. [StyleBox] used when the [OptionButton] is being pressed.
  231. </theme_item>
  232. </theme_items>
  233. </class>