2
0

class_texturebutton.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/TextureButton.xml.
  6. .. _class_TextureButton:
  7. TextureButton
  8. =============
  9. **Inherits:** :ref:`BaseButton<class_BaseButton>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Texture-based button. Supports Pressed, Hover, Disabled and Focused states.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **TextureButton** has the same functionality as :ref:`Button<class_Button>`, except it uses sprites instead of Godot's :ref:`Theme<class_Theme>` resource. It is faster to create, but it doesn't support localization like more complex :ref:`Control<class_Control>`\ s.
  15. The "normal" state must contain a texture (:ref:`texture_normal<class_TextureButton_property_texture_normal>`); other textures are optional.
  16. See also :ref:`BaseButton<class_BaseButton>` which contains common properties and methods associated with this node.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  27. | :ref:`bool<class_bool>` | :ref:`expand<class_TextureButton_property_expand>` | ``false`` |
  28. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  29. | :ref:`bool<class_bool>` | :ref:`flip_h<class_TextureButton_property_flip_h>` | ``false`` |
  30. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  31. | :ref:`bool<class_bool>` | :ref:`flip_v<class_TextureButton_property_flip_v>` | ``false`` |
  32. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  33. | :ref:`StretchMode<enum_TextureButton_StretchMode>` | :ref:`stretch_mode<class_TextureButton_property_stretch_mode>` | ``0`` |
  34. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  35. | :ref:`BitMap<class_BitMap>` | :ref:`texture_click_mask<class_TextureButton_property_texture_click_mask>` | |
  36. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  37. | :ref:`Texture<class_Texture>` | :ref:`texture_disabled<class_TextureButton_property_texture_disabled>` | |
  38. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  39. | :ref:`Texture<class_Texture>` | :ref:`texture_focused<class_TextureButton_property_texture_focused>` | |
  40. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  41. | :ref:`Texture<class_Texture>` | :ref:`texture_hover<class_TextureButton_property_texture_hover>` | |
  42. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  43. | :ref:`Texture<class_Texture>` | :ref:`texture_normal<class_TextureButton_property_texture_normal>` | |
  44. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  45. | :ref:`Texture<class_Texture>` | :ref:`texture_pressed<class_TextureButton_property_texture_pressed>` | |
  46. +----------------------------------------------------+----------------------------------------------------------------------------+-----------+
  47. .. rst-class:: classref-section-separator
  48. ----
  49. .. rst-class:: classref-descriptions-group
  50. Enumerations
  51. ------------
  52. .. _enum_TextureButton_StretchMode:
  53. .. rst-class:: classref-enumeration
  54. enum **StretchMode**:
  55. .. _class_TextureButton_constant_STRETCH_SCALE:
  56. .. rst-class:: classref-enumeration-constant
  57. :ref:`StretchMode<enum_TextureButton_StretchMode>` **STRETCH_SCALE** = ``0``
  58. Scale to fit the node's bounding rectangle.
  59. .. _class_TextureButton_constant_STRETCH_TILE:
  60. .. rst-class:: classref-enumeration-constant
  61. :ref:`StretchMode<enum_TextureButton_StretchMode>` **STRETCH_TILE** = ``1``
  62. Tile inside the node's bounding rectangle.
  63. .. _class_TextureButton_constant_STRETCH_KEEP:
  64. .. rst-class:: classref-enumeration-constant
  65. :ref:`StretchMode<enum_TextureButton_StretchMode>` **STRETCH_KEEP** = ``2``
  66. The texture keeps its original size and stays in the bounding rectangle's top-left corner.
  67. .. _class_TextureButton_constant_STRETCH_KEEP_CENTERED:
  68. .. rst-class:: classref-enumeration-constant
  69. :ref:`StretchMode<enum_TextureButton_StretchMode>` **STRETCH_KEEP_CENTERED** = ``3``
  70. The texture keeps its original size and stays centered in the node's bounding rectangle.
  71. .. _class_TextureButton_constant_STRETCH_KEEP_ASPECT:
  72. .. rst-class:: classref-enumeration-constant
  73. :ref:`StretchMode<enum_TextureButton_StretchMode>` **STRETCH_KEEP_ASPECT** = ``4``
  74. Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
  75. .. _class_TextureButton_constant_STRETCH_KEEP_ASPECT_CENTERED:
  76. .. rst-class:: classref-enumeration-constant
  77. :ref:`StretchMode<enum_TextureButton_StretchMode>` **STRETCH_KEEP_ASPECT_CENTERED** = ``5``
  78. Scale the texture to fit the node's bounding rectangle, center it, and maintain its aspect ratio.
  79. .. _class_TextureButton_constant_STRETCH_KEEP_ASPECT_COVERED:
  80. .. rst-class:: classref-enumeration-constant
  81. :ref:`StretchMode<enum_TextureButton_StretchMode>` **STRETCH_KEEP_ASPECT_COVERED** = ``6``
  82. Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.
  83. .. rst-class:: classref-section-separator
  84. ----
  85. .. rst-class:: classref-descriptions-group
  86. Property Descriptions
  87. ---------------------
  88. .. _class_TextureButton_property_expand:
  89. .. rst-class:: classref-property
  90. :ref:`bool<class_bool>` **expand** = ``false``
  91. .. rst-class:: classref-property-setget
  92. - void **set_expand** **(** :ref:`bool<class_bool>` value **)**
  93. - :ref:`bool<class_bool>` **get_expand** **(** **)**
  94. If ``true``, the texture stretches to the edges of the node's bounding rectangle using the :ref:`stretch_mode<class_TextureButton_property_stretch_mode>`. If ``false``, the texture will not scale with the node.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_TextureButton_property_flip_h:
  98. .. rst-class:: classref-property
  99. :ref:`bool<class_bool>` **flip_h** = ``false``
  100. .. rst-class:: classref-property-setget
  101. - void **set_flip_h** **(** :ref:`bool<class_bool>` value **)**
  102. - :ref:`bool<class_bool>` **is_flipped_h** **(** **)**
  103. If ``true``, texture is flipped horizontally.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_TextureButton_property_flip_v:
  107. .. rst-class:: classref-property
  108. :ref:`bool<class_bool>` **flip_v** = ``false``
  109. .. rst-class:: classref-property-setget
  110. - void **set_flip_v** **(** :ref:`bool<class_bool>` value **)**
  111. - :ref:`bool<class_bool>` **is_flipped_v** **(** **)**
  112. If ``true``, texture is flipped vertically.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_TextureButton_property_stretch_mode:
  116. .. rst-class:: classref-property
  117. :ref:`StretchMode<enum_TextureButton_StretchMode>` **stretch_mode** = ``0``
  118. .. rst-class:: classref-property-setget
  119. - void **set_stretch_mode** **(** :ref:`StretchMode<enum_TextureButton_StretchMode>` value **)**
  120. - :ref:`StretchMode<enum_TextureButton_StretchMode>` **get_stretch_mode** **(** **)**
  121. Controls the texture's behavior when you resize the node's bounding rectangle, **only if** :ref:`expand<class_TextureButton_property_expand>` is ``true``. Set it to one of the :ref:`StretchMode<enum_TextureButton_StretchMode>` constants. See the constants to learn more.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_TextureButton_property_texture_click_mask:
  125. .. rst-class:: classref-property
  126. :ref:`BitMap<class_BitMap>` **texture_click_mask**
  127. .. rst-class:: classref-property-setget
  128. - void **set_click_mask** **(** :ref:`BitMap<class_BitMap>` value **)**
  129. - :ref:`BitMap<class_BitMap>` **get_click_mask** **(** **)**
  130. Pure black and white :ref:`BitMap<class_BitMap>` image to use for click detection. On the mask, white pixels represent the button's clickable area. Use it to create buttons with curved shapes.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_TextureButton_property_texture_disabled:
  134. .. rst-class:: classref-property
  135. :ref:`Texture<class_Texture>` **texture_disabled**
  136. .. rst-class:: classref-property-setget
  137. - void **set_disabled_texture** **(** :ref:`Texture<class_Texture>` value **)**
  138. - :ref:`Texture<class_Texture>` **get_disabled_texture** **(** **)**
  139. Texture to display when the node is disabled. See :ref:`BaseButton.disabled<class_BaseButton_property_disabled>`.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_TextureButton_property_texture_focused:
  143. .. rst-class:: classref-property
  144. :ref:`Texture<class_Texture>` **texture_focused**
  145. .. rst-class:: classref-property-setget
  146. - void **set_focused_texture** **(** :ref:`Texture<class_Texture>` value **)**
  147. - :ref:`Texture<class_Texture>` **get_focused_texture** **(** **)**
  148. Texture to display when the node has mouse or keyboard focus.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_TextureButton_property_texture_hover:
  152. .. rst-class:: classref-property
  153. :ref:`Texture<class_Texture>` **texture_hover**
  154. .. rst-class:: classref-property-setget
  155. - void **set_hover_texture** **(** :ref:`Texture<class_Texture>` value **)**
  156. - :ref:`Texture<class_Texture>` **get_hover_texture** **(** **)**
  157. Texture to display when the mouse hovers the node.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_TextureButton_property_texture_normal:
  161. .. rst-class:: classref-property
  162. :ref:`Texture<class_Texture>` **texture_normal**
  163. .. rst-class:: classref-property-setget
  164. - void **set_normal_texture** **(** :ref:`Texture<class_Texture>` value **)**
  165. - :ref:`Texture<class_Texture>` **get_normal_texture** **(** **)**
  166. Texture to display by default, when the node is **not** in the disabled, focused, hover or pressed state.
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_TextureButton_property_texture_pressed:
  170. .. rst-class:: classref-property
  171. :ref:`Texture<class_Texture>` **texture_pressed**
  172. .. rst-class:: classref-property-setget
  173. - void **set_pressed_texture** **(** :ref:`Texture<class_Texture>` value **)**
  174. - :ref:`Texture<class_Texture>` **get_pressed_texture** **(** **)**
  175. Texture to display on mouse down over the node, if the node has keyboard focus and the player presses the Enter key or if the player presses the :ref:`BaseButton.shortcut<class_BaseButton_property_shortcut>` key.
  176. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  177. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  178. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  179. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`