class_texturebutton.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. Description
  12. -----------
  13. ``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.
  14. The "normal" state must contain a texture (:ref:`texture_normal<class_TextureButton_property_texture_normal>`); other textures are optional.
  15. See also :ref:`BaseButton<class_BaseButton>` which contains common properties and methods associated with this node.
  16. Tutorials
  17. ---------
  18. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
  19. Properties
  20. ----------
  21. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  22. | :ref:`bool<class_bool>` | :ref:`flip_h<class_TextureButton_property_flip_h>` | ``false`` |
  23. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  24. | :ref:`bool<class_bool>` | :ref:`flip_v<class_TextureButton_property_flip_v>` | ``false`` |
  25. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  26. | :ref:`bool<class_bool>` | :ref:`ignore_texture_size<class_TextureButton_property_ignore_texture_size>` | ``false`` |
  27. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  28. | :ref:`StretchMode<enum_TextureButton_StretchMode>` | :ref:`stretch_mode<class_TextureButton_property_stretch_mode>` | ``2`` |
  29. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  30. | :ref:`BitMap<class_BitMap>` | :ref:`texture_click_mask<class_TextureButton_property_texture_click_mask>` | |
  31. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  32. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_disabled<class_TextureButton_property_texture_disabled>` | |
  33. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  34. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_focused<class_TextureButton_property_texture_focused>` | |
  35. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  36. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_hover<class_TextureButton_property_texture_hover>` | |
  37. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  38. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_normal<class_TextureButton_property_texture_normal>` | |
  39. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  40. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_pressed<class_TextureButton_property_texture_pressed>` | |
  41. +----------------------------------------------------+------------------------------------------------------------------------------+-----------+
  42. Enumerations
  43. ------------
  44. .. _enum_TextureButton_StretchMode:
  45. .. _class_TextureButton_constant_STRETCH_SCALE:
  46. .. _class_TextureButton_constant_STRETCH_TILE:
  47. .. _class_TextureButton_constant_STRETCH_KEEP:
  48. .. _class_TextureButton_constant_STRETCH_KEEP_CENTERED:
  49. .. _class_TextureButton_constant_STRETCH_KEEP_ASPECT:
  50. .. _class_TextureButton_constant_STRETCH_KEEP_ASPECT_CENTERED:
  51. .. _class_TextureButton_constant_STRETCH_KEEP_ASPECT_COVERED:
  52. enum **StretchMode**:
  53. - **STRETCH_SCALE** = **0** --- Scale to fit the node's bounding rectangle.
  54. - **STRETCH_TILE** = **1** --- Tile inside the node's bounding rectangle.
  55. - **STRETCH_KEEP** = **2** --- The texture keeps its original size and stays in the bounding rectangle's top-left corner.
  56. - **STRETCH_KEEP_CENTERED** = **3** --- The texture keeps its original size and stays centered in the node's bounding rectangle.
  57. - **STRETCH_KEEP_ASPECT** = **4** --- Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
  58. - **STRETCH_KEEP_ASPECT_CENTERED** = **5** --- Scale the texture to fit the node's bounding rectangle, center it, and maintain its aspect ratio.
  59. - **STRETCH_KEEP_ASPECT_COVERED** = **6** --- Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.
  60. Property Descriptions
  61. ---------------------
  62. .. _class_TextureButton_property_flip_h:
  63. - :ref:`bool<class_bool>` **flip_h**
  64. +-----------+-------------------+
  65. | *Default* | ``false`` |
  66. +-----------+-------------------+
  67. | *Setter* | set_flip_h(value) |
  68. +-----------+-------------------+
  69. | *Getter* | is_flipped_h() |
  70. +-----------+-------------------+
  71. If ``true``, texture is flipped horizontally.
  72. ----
  73. .. _class_TextureButton_property_flip_v:
  74. - :ref:`bool<class_bool>` **flip_v**
  75. +-----------+-------------------+
  76. | *Default* | ``false`` |
  77. +-----------+-------------------+
  78. | *Setter* | set_flip_v(value) |
  79. +-----------+-------------------+
  80. | *Getter* | is_flipped_v() |
  81. +-----------+-------------------+
  82. If ``true``, texture is flipped vertically.
  83. ----
  84. .. _class_TextureButton_property_ignore_texture_size:
  85. - :ref:`bool<class_bool>` **ignore_texture_size**
  86. +-----------+--------------------------------+
  87. | *Default* | ``false`` |
  88. +-----------+--------------------------------+
  89. | *Setter* | set_ignore_texture_size(value) |
  90. +-----------+--------------------------------+
  91. | *Getter* | get_ignore_texture_size() |
  92. +-----------+--------------------------------+
  93. 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.
  94. ----
  95. .. _class_TextureButton_property_stretch_mode:
  96. - :ref:`StretchMode<enum_TextureButton_StretchMode>` **stretch_mode**
  97. +-----------+-------------------------+
  98. | *Default* | ``2`` |
  99. +-----------+-------------------------+
  100. | *Setter* | set_stretch_mode(value) |
  101. +-----------+-------------------------+
  102. | *Getter* | get_stretch_mode() |
  103. +-----------+-------------------------+
  104. Controls the texture's behavior when you resize the node's bounding rectangle. See the :ref:`StretchMode<enum_TextureButton_StretchMode>` constants for available options.
  105. ----
  106. .. _class_TextureButton_property_texture_click_mask:
  107. - :ref:`BitMap<class_BitMap>` **texture_click_mask**
  108. +----------+-----------------------+
  109. | *Setter* | set_click_mask(value) |
  110. +----------+-----------------------+
  111. | *Getter* | get_click_mask() |
  112. +----------+-----------------------+
  113. 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.
  114. ----
  115. .. _class_TextureButton_property_texture_disabled:
  116. - :ref:`Texture2D<class_Texture2D>` **texture_disabled**
  117. +----------+-----------------------------+
  118. | *Setter* | set_disabled_texture(value) |
  119. +----------+-----------------------------+
  120. | *Getter* | get_disabled_texture() |
  121. +----------+-----------------------------+
  122. Texture to display when the node is disabled. See :ref:`BaseButton.disabled<class_BaseButton_property_disabled>`.
  123. ----
  124. .. _class_TextureButton_property_texture_focused:
  125. - :ref:`Texture2D<class_Texture2D>` **texture_focused**
  126. +----------+----------------------------+
  127. | *Setter* | set_focused_texture(value) |
  128. +----------+----------------------------+
  129. | *Getter* | get_focused_texture() |
  130. +----------+----------------------------+
  131. 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.
  132. ----
  133. .. _class_TextureButton_property_texture_hover:
  134. - :ref:`Texture2D<class_Texture2D>` **texture_hover**
  135. +----------+--------------------------+
  136. | *Setter* | set_hover_texture(value) |
  137. +----------+--------------------------+
  138. | *Getter* | get_hover_texture() |
  139. +----------+--------------------------+
  140. Texture to display when the mouse hovers the node.
  141. ----
  142. .. _class_TextureButton_property_texture_normal:
  143. - :ref:`Texture2D<class_Texture2D>` **texture_normal**
  144. +----------+---------------------------+
  145. | *Setter* | set_normal_texture(value) |
  146. +----------+---------------------------+
  147. | *Getter* | get_normal_texture() |
  148. +----------+---------------------------+
  149. Texture to display by default, when the node is **not** in the disabled, focused, hover or pressed state.
  150. ----
  151. .. _class_TextureButton_property_texture_pressed:
  152. - :ref:`Texture2D<class_Texture2D>` **texture_pressed**
  153. +----------+----------------------------+
  154. | *Setter* | set_pressed_texture(value) |
  155. +----------+----------------------------+
  156. | *Getter* | get_pressed_texture() |
  157. +----------+----------------------------+
  158. 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.
  159. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  160. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  161. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  162. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  163. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  164. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`