Button.xml 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Button" inherits="BaseButton" version="3.3">
  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. </member>
  44. <member name="text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
  45. The button's text that will be displayed inside the button's area.
  46. </member>
  47. </members>
  48. <constants>
  49. <constant name="ALIGN_LEFT" value="0" enum="TextAlign">
  50. Align the text to the left.
  51. </constant>
  52. <constant name="ALIGN_CENTER" value="1" enum="TextAlign">
  53. Align the text to the center.
  54. </constant>
  55. <constant name="ALIGN_RIGHT" value="2" enum="TextAlign">
  56. Align the text to the right.
  57. </constant>
  58. </constants>
  59. <theme_items>
  60. <theme_item name="disabled" type="StyleBox">
  61. [StyleBox] used when the [Button] is disabled.
  62. </theme_item>
  63. <theme_item name="focus" type="StyleBox">
  64. [StyleBox] used when the [Button] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect.
  65. </theme_item>
  66. <theme_item name="font" type="Font">
  67. [Font] of the [Button]'s text.
  68. </theme_item>
  69. <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
  70. Default text [Color] of the [Button].
  71. </theme_item>
  72. <theme_item name="font_color_disabled" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
  73. Text [Color] used when the [Button] is disabled.
  74. </theme_item>
  75. <theme_item name="font_color_hover" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
  76. Text [Color] used when the [Button] is being hovered.
  77. </theme_item>
  78. <theme_item name="font_color_pressed" type="Color" default="Color( 1, 1, 1, 1 )">
  79. Text [Color] used when the [Button] is being pressed.
  80. </theme_item>
  81. <theme_item name="hover" type="StyleBox">
  82. [StyleBox] used when the [Button] is being hovered.
  83. </theme_item>
  84. <theme_item name="hseparation" type="int" default="2">
  85. The horizontal space between [Button]'s icon and text.
  86. </theme_item>
  87. <theme_item name="normal" type="StyleBox">
  88. Default [StyleBox] for the [Button].
  89. </theme_item>
  90. <theme_item name="pressed" type="StyleBox">
  91. [StyleBox] used when the [Button] is being pressed.
  92. </theme_item>
  93. </theme_items>
  94. </class>