class_texturebutton.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/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:`flip_h<class_TextureButton_property_flip_h>` | ``false`` |
  28. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  29. | :ref:`bool<class_bool>` | :ref:`flip_v<class_TextureButton_property_flip_v>` | ``false`` |
  30. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  31. | :ref:`bool<class_bool>` | :ref:`ignore_texture_size<class_TextureButton_property_ignore_texture_size>` | ``false`` |
  32. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  33. | :ref:`StretchMode<enum_TextureButton_StretchMode>` | :ref:`stretch_mode<class_TextureButton_property_stretch_mode>` | ``2`` |
  34. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  35. | :ref:`BitMap<class_BitMap>` | :ref:`texture_click_mask<class_TextureButton_property_texture_click_mask>` | |
  36. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  37. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_disabled<class_TextureButton_property_texture_disabled>` | |
  38. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  39. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_focused<class_TextureButton_property_texture_focused>` | |
  40. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  41. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_hover<class_TextureButton_property_texture_hover>` | |
  42. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  43. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_normal<class_TextureButton_property_texture_normal>` | |
  44. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  45. | :ref:`Texture2D<class_Texture2D>` | :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_flip_h:
  89. .. rst-class:: classref-property
  90. :ref:`bool<class_bool>` **flip_h** = ``false``
  91. .. rst-class:: classref-property-setget
  92. - void **set_flip_h** **(** :ref:`bool<class_bool>` value **)**
  93. - :ref:`bool<class_bool>` **is_flipped_h** **(** **)**
  94. If ``true``, texture is flipped horizontally.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_TextureButton_property_flip_v:
  98. .. rst-class:: classref-property
  99. :ref:`bool<class_bool>` **flip_v** = ``false``
  100. .. rst-class:: classref-property-setget
  101. - void **set_flip_v** **(** :ref:`bool<class_bool>` value **)**
  102. - :ref:`bool<class_bool>` **is_flipped_v** **(** **)**
  103. If ``true``, texture is flipped vertically.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_TextureButton_property_ignore_texture_size:
  107. .. rst-class:: classref-property
  108. :ref:`bool<class_bool>` **ignore_texture_size** = ``false``
  109. .. rst-class:: classref-property-setget
  110. - void **set_ignore_texture_size** **(** :ref:`bool<class_bool>` value **)**
  111. - :ref:`bool<class_bool>` **get_ignore_texture_size** **(** **)**
  112. If ``true``, the size of the texture won't be considered for minimum size calculation, so the **TextureButton** can be shrunk down past the texture size.
  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** = ``2``
  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. See the :ref:`StretchMode<enum_TextureButton_StretchMode>` constants for available options.
  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:`Texture2D<class_Texture2D>` **texture_disabled**
  136. .. rst-class:: classref-property-setget
  137. - void **set_texture_disabled** **(** :ref:`Texture2D<class_Texture2D>` value **)**
  138. - :ref:`Texture2D<class_Texture2D>` **get_texture_disabled** **(** **)**
  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:`Texture2D<class_Texture2D>` **texture_focused**
  145. .. rst-class:: classref-property-setget
  146. - void **set_texture_focused** **(** :ref:`Texture2D<class_Texture2D>` value **)**
  147. - :ref:`Texture2D<class_Texture2D>` **get_texture_focused** **(** **)**
  148. Texture to display when the node has mouse or keyboard focus. :ref:`texture_focused<class_TextureButton_property_texture_focused>` is displayed *over* the base texture, so a partially transparent texture should be used to ensure the base texture remains visible. A texture that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a fully transparent texture of any size. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_TextureButton_property_texture_hover:
  152. .. rst-class:: classref-property
  153. :ref:`Texture2D<class_Texture2D>` **texture_hover**
  154. .. rst-class:: classref-property-setget
  155. - void **set_texture_hover** **(** :ref:`Texture2D<class_Texture2D>` value **)**
  156. - :ref:`Texture2D<class_Texture2D>` **get_texture_hover** **(** **)**
  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:`Texture2D<class_Texture2D>` **texture_normal**
  163. .. rst-class:: classref-property-setget
  164. - void **set_texture_normal** **(** :ref:`Texture2D<class_Texture2D>` value **)**
  165. - :ref:`Texture2D<class_Texture2D>` **get_texture_normal** **(** **)**
  166. Texture to display by default, when the node is **not** in the disabled, hover or pressed state. This texture is still displayed in the focused state, with :ref:`texture_focused<class_TextureButton_property_texture_focused>` drawn on top.
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_TextureButton_property_texture_pressed:
  170. .. rst-class:: classref-property
  171. :ref:`Texture2D<class_Texture2D>` **texture_pressed**
  172. .. rst-class:: classref-property-setget
  173. - void **set_texture_pressed** **(** :ref:`Texture2D<class_Texture2D>` value **)**
  174. - :ref:`Texture2D<class_Texture2D>` **get_texture_pressed** **(** **)**
  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. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  180. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  181. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  182. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`