class_button.rst 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Button.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Button:
  6. Button
  7. ======
  8. **Inherits:** :ref:`BaseButton<class_BaseButton>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`CheckBox<class_CheckBox>`, :ref:`CheckButton<class_CheckButton>`, :ref:`ColorPickerButton<class_ColorPickerButton>`, :ref:`MenuButton<class_MenuButton>`, :ref:`OptionButton<class_OptionButton>`, :ref:`ToolButton<class_ToolButton>`
  10. Standard themed Button.
  11. Description
  12. -----------
  13. Button is the standard themed button. It can contain text and an icon, and will display them according to the current :ref:`Theme<class_Theme>`.
  14. Properties
  15. ----------
  16. +-----------------------------------------+-------------------------------------------------------+-----------+
  17. | :ref:`TextAlign<enum_Button_TextAlign>` | :ref:`align<class_Button_property_align>` | ``1`` |
  18. +-----------------------------------------+-------------------------------------------------------+-----------+
  19. | :ref:`bool<class_bool>` | :ref:`clip_text<class_Button_property_clip_text>` | ``false`` |
  20. +-----------------------------------------+-------------------------------------------------------+-----------+
  21. | :ref:`bool<class_bool>` | :ref:`expand_icon<class_Button_property_expand_icon>` | ``false`` |
  22. +-----------------------------------------+-------------------------------------------------------+-----------+
  23. | :ref:`bool<class_bool>` | :ref:`flat<class_Button_property_flat>` | ``false`` |
  24. +-----------------------------------------+-------------------------------------------------------+-----------+
  25. | :ref:`Texture2D<class_Texture2D>` | :ref:`icon<class_Button_property_icon>` | |
  26. +-----------------------------------------+-------------------------------------------------------+-----------+
  27. | :ref:`String<class_String>` | :ref:`text<class_Button_property_text>` | ``""`` |
  28. +-----------------------------------------+-------------------------------------------------------+-----------+
  29. Theme Properties
  30. ----------------
  31. +---------------------------------+---------------------+------------------------------+
  32. | :ref:`StyleBox<class_StyleBox>` | disabled | |
  33. +---------------------------------+---------------------+------------------------------+
  34. | :ref:`StyleBox<class_StyleBox>` | focus | |
  35. +---------------------------------+---------------------+------------------------------+
  36. | :ref:`Font<class_Font>` | font | |
  37. +---------------------------------+---------------------+------------------------------+
  38. | :ref:`Color<class_Color>` | font_color | Color( 0.88, 0.88, 0.88, 1 ) |
  39. +---------------------------------+---------------------+------------------------------+
  40. | :ref:`Color<class_Color>` | font_color_disabled | Color( 0.9, 0.9, 0.9, 0.2 ) |
  41. +---------------------------------+---------------------+------------------------------+
  42. | :ref:`Color<class_Color>` | font_color_hover | Color( 0.94, 0.94, 0.94, 1 ) |
  43. +---------------------------------+---------------------+------------------------------+
  44. | :ref:`Color<class_Color>` | font_color_pressed | Color( 1, 1, 1, 1 ) |
  45. +---------------------------------+---------------------+------------------------------+
  46. | :ref:`StyleBox<class_StyleBox>` | hover | |
  47. +---------------------------------+---------------------+------------------------------+
  48. | :ref:`int<class_int>` | hseparation | 2 |
  49. +---------------------------------+---------------------+------------------------------+
  50. | :ref:`StyleBox<class_StyleBox>` | normal | |
  51. +---------------------------------+---------------------+------------------------------+
  52. | :ref:`StyleBox<class_StyleBox>` | pressed | |
  53. +---------------------------------+---------------------+------------------------------+
  54. Enumerations
  55. ------------
  56. .. _enum_Button_TextAlign:
  57. .. _class_Button_constant_ALIGN_LEFT:
  58. .. _class_Button_constant_ALIGN_CENTER:
  59. .. _class_Button_constant_ALIGN_RIGHT:
  60. enum **TextAlign**:
  61. - **ALIGN_LEFT** = **0** --- Align the text to the left.
  62. - **ALIGN_CENTER** = **1** --- Align the text to the center.
  63. - **ALIGN_RIGHT** = **2** --- Align the text to the right.
  64. Property Descriptions
  65. ---------------------
  66. .. _class_Button_property_align:
  67. - :ref:`TextAlign<enum_Button_TextAlign>` **align**
  68. +-----------+-----------------------+
  69. | *Default* | ``1`` |
  70. +-----------+-----------------------+
  71. | *Setter* | set_text_align(value) |
  72. +-----------+-----------------------+
  73. | *Getter* | get_text_align() |
  74. +-----------+-----------------------+
  75. Text alignment policy for the button's text, use one of the :ref:`TextAlign<enum_Button_TextAlign>` constants.
  76. ----
  77. .. _class_Button_property_clip_text:
  78. - :ref:`bool<class_bool>` **clip_text**
  79. +-----------+----------------------+
  80. | *Default* | ``false`` |
  81. +-----------+----------------------+
  82. | *Setter* | set_clip_text(value) |
  83. +-----------+----------------------+
  84. | *Getter* | get_clip_text() |
  85. +-----------+----------------------+
  86. 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.
  87. ----
  88. .. _class_Button_property_expand_icon:
  89. - :ref:`bool<class_bool>` **expand_icon**
  90. +-----------+------------------------+
  91. | *Default* | ``false`` |
  92. +-----------+------------------------+
  93. | *Setter* | set_expand_icon(value) |
  94. +-----------+------------------------+
  95. | *Getter* | is_expand_icon() |
  96. +-----------+------------------------+
  97. When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect.
  98. ----
  99. .. _class_Button_property_flat:
  100. - :ref:`bool<class_bool>` **flat**
  101. +-----------+-----------------+
  102. | *Default* | ``false`` |
  103. +-----------+-----------------+
  104. | *Setter* | set_flat(value) |
  105. +-----------+-----------------+
  106. | *Getter* | is_flat() |
  107. +-----------+-----------------+
  108. Flat buttons don't display decoration.
  109. ----
  110. .. _class_Button_property_icon:
  111. - :ref:`Texture2D<class_Texture2D>` **icon**
  112. +----------+------------------------+
  113. | *Setter* | set_button_icon(value) |
  114. +----------+------------------------+
  115. | *Getter* | get_button_icon() |
  116. +----------+------------------------+
  117. Button's icon, if text is present the icon will be placed before the text.
  118. ----
  119. .. _class_Button_property_text:
  120. - :ref:`String<class_String>` **text**
  121. +-----------+-----------------+
  122. | *Default* | ``""`` |
  123. +-----------+-----------------+
  124. | *Setter* | set_text(value) |
  125. +-----------+-----------------+
  126. | *Getter* | get_text() |
  127. +-----------+-----------------+
  128. The button's text that will be displayed inside the button's area.