Button.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Button" inherits="BaseButton" version="3.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Standard themed Button.
  5. </brief_description>
  6. <description>
  7. Button is the standard themed button. It can contain text and an icon, and will display them according to the current [Theme].
  8. [b]Example of creating a button and assigning an action when pressed by code:[/b]
  9. [codeblock]
  10. func _ready():
  11. var button = Button.new()
  12. button.text = "Click me"
  13. button.connect("pressed", self, "_button_pressed")
  14. add_child(button)
  15. func _button_pressed():
  16. print("Hello world!")
  17. [/codeblock]
  18. Buttons (like all Control nodes) can also be created in the editor, but some situations may require creating them from code.
  19. See also [BaseButton] which contains common properties and methods associated with this node.
  20. [b]Note:[/b] Buttons do not interpret touch input and therefore don't support multitouch, since mouse emulation can only press one button at a given time. Use [TouchScreenButton] for buttons that trigger gameplay movement or actions, as [TouchScreenButton] supports multitouch.
  21. </description>
  22. <tutorials>
  23. <link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/515</link>
  24. <link title="OS Test Demo">https://godotengine.org/asset-library/asset/677</link>
  25. </tutorials>
  26. <methods>
  27. </methods>
  28. <members>
  29. <member name="align" type="int" setter="set_text_align" getter="get_text_align" enum="Button.TextAlign" default="1">
  30. Text alignment policy for the button's text, use one of the [enum TextAlign] constants.
  31. </member>
  32. <member name="clip_text" type="bool" setter="set_clip_text" getter="get_clip_text" default="false">
  33. When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text.
  34. </member>
  35. <member name="expand_icon" type="bool" setter="set_expand_icon" getter="is_expand_icon" default="false">
  36. When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect.
  37. </member>
  38. <member name="flat" type="bool" setter="set_flat" getter="is_flat" default="false">
  39. Flat buttons don't display decoration.
  40. </member>
  41. <member name="icon" type="Texture" setter="set_button_icon" getter="get_button_icon">
  42. Button's icon, if text is present the icon will be placed before the text.
  43. To edit margin and spacing of the icon, use [code]hseparation[/code] theme property of [Button] and [code]content_margin_*[/code] properties of the used [StyleBox]es.
  44. </member>
  45. <member name="icon_align" type="int" setter="set_icon_align" getter="get_icon_align" enum="Button.TextAlign" default="0">
  46. Specifies if the icon should be aligned to the left, right, or center of a button. Uses the same [enum TextAlign] constants as the text alignment. If centered, text will draw on top of the icon.
  47. </member>
  48. <member name="text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
  49. The button's text that will be displayed inside the button's area.
  50. </member>
  51. </members>
  52. <constants>
  53. <constant name="ALIGN_LEFT" value="0" enum="TextAlign">
  54. Align the text to the left.
  55. </constant>
  56. <constant name="ALIGN_CENTER" value="1" enum="TextAlign">
  57. Align the text to the center.
  58. </constant>
  59. <constant name="ALIGN_RIGHT" value="2" enum="TextAlign">
  60. Align the text to the right.
  61. </constant>
  62. </constants>
  63. <theme_items>
  64. <theme_item name="font_color" data_type="color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
  65. Default text [Color] of the [Button].
  66. </theme_item>
  67. <theme_item name="font_color_disabled" data_type="color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
  68. Text [Color] used when the [Button] is disabled.
  69. </theme_item>
  70. <theme_item name="font_color_focus" data_type="color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
  71. Text [Color] used when the [Button] is focused. Only replaces the normal text color of the button. Disabled, hovered, and pressed states take precedence over this color.
  72. </theme_item>
  73. <theme_item name="font_color_hover" data_type="color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
  74. Text [Color] used when the [Button] is being hovered.
  75. </theme_item>
  76. <theme_item name="font_color_hover_pressed" data_type="color" type="Color" default="Color( 1, 1, 1, 1 )">
  77. Text [Color] used when the [Button] is being hovered and pressed.
  78. </theme_item>
  79. <theme_item name="font_color_pressed" data_type="color" type="Color" default="Color( 1, 1, 1, 1 )">
  80. Text [Color] used when the [Button] is being pressed.
  81. </theme_item>
  82. <theme_item name="icon_color_disabled" data_type="color" type="Color" default="Color( 1, 1, 1, 0.4 )">
  83. Icon modulate [Color] used when the [Button] is disabled.
  84. </theme_item>
  85. <theme_item name="icon_color_focus" data_type="color" type="Color" default="Color( 1, 1, 1, 1 )">
  86. Icon modulate [Color] used when the [Button] is focused. Only replaces the normal modulate color of the button. Disabled, hovered, and pressed states take precedence over this color.
  87. </theme_item>
  88. <theme_item name="icon_color_hover" data_type="color" type="Color" default="Color( 1, 1, 1, 1 )">
  89. Icon modulate [Color] used when the [Button] is being hovered.
  90. </theme_item>
  91. <theme_item name="icon_color_hover_pressed" data_type="color" type="Color" default="Color( 1, 1, 1, 1 )">
  92. Icon modulate [Color] used when the [Button] is being hovered and pressed.
  93. </theme_item>
  94. <theme_item name="icon_color_normal" data_type="color" type="Color" default="Color( 1, 1, 1, 1 )">
  95. Default icon modulate [Color] of the [Button].
  96. </theme_item>
  97. <theme_item name="icon_color_pressed" data_type="color" type="Color" default="Color( 1, 1, 1, 1 )">
  98. Icon modulate [Color] used when the [Button] is being pressed.
  99. </theme_item>
  100. <theme_item name="hseparation" data_type="constant" type="int" default="2">
  101. The horizontal space between [Button]'s icon and text.
  102. </theme_item>
  103. <theme_item name="font" data_type="font" type="Font">
  104. [Font] of the [Button]'s text.
  105. </theme_item>
  106. <theme_item name="disabled" data_type="style" type="StyleBox">
  107. [StyleBox] used when the [Button] is disabled.
  108. </theme_item>
  109. <theme_item name="focus" data_type="style" type="StyleBox">
  110. [StyleBox] used when the [Button] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect.
  111. </theme_item>
  112. <theme_item name="hover" data_type="style" type="StyleBox">
  113. [StyleBox] used when the [Button] is being hovered.
  114. </theme_item>
  115. <theme_item name="normal" data_type="style" type="StyleBox">
  116. Default [StyleBox] for the [Button].
  117. </theme_item>
  118. <theme_item name="pressed" data_type="style" type="StyleBox">
  119. [StyleBox] used when the [Button] is being pressed.
  120. </theme_item>
  121. </theme_items>
  122. </class>