class_texturebutton.rst 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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 TextureButton.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_TextureButton:
  6. TextureButton
  7. =============
  8. **Inherits:** :ref:`BaseButton<class_BaseButton>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Texture-based button. Supports Pressed, Hover, Disabled and Focused states.
  13. Properties
  14. ----------
  15. +----------------------------------------------------+----------------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`expand<class_TextureButton_property_expand>` |
  17. +----------------------------------------------------+----------------------------------------------------------------------------+
  18. | :ref:`StretchMode<enum_TextureButton_StretchMode>` | :ref:`stretch_mode<class_TextureButton_property_stretch_mode>` |
  19. +----------------------------------------------------+----------------------------------------------------------------------------+
  20. | :ref:`BitMap<class_BitMap>` | :ref:`texture_click_mask<class_TextureButton_property_texture_click_mask>` |
  21. +----------------------------------------------------+----------------------------------------------------------------------------+
  22. | :ref:`Texture<class_Texture>` | :ref:`texture_disabled<class_TextureButton_property_texture_disabled>` |
  23. +----------------------------------------------------+----------------------------------------------------------------------------+
  24. | :ref:`Texture<class_Texture>` | :ref:`texture_focused<class_TextureButton_property_texture_focused>` |
  25. +----------------------------------------------------+----------------------------------------------------------------------------+
  26. | :ref:`Texture<class_Texture>` | :ref:`texture_hover<class_TextureButton_property_texture_hover>` |
  27. +----------------------------------------------------+----------------------------------------------------------------------------+
  28. | :ref:`Texture<class_Texture>` | :ref:`texture_normal<class_TextureButton_property_texture_normal>` |
  29. +----------------------------------------------------+----------------------------------------------------------------------------+
  30. | :ref:`Texture<class_Texture>` | :ref:`texture_pressed<class_TextureButton_property_texture_pressed>` |
  31. +----------------------------------------------------+----------------------------------------------------------------------------+
  32. Enumerations
  33. ------------
  34. .. _enum_TextureButton_StretchMode:
  35. .. _class_TextureButton_constant_STRETCH_SCALE:
  36. .. _class_TextureButton_constant_STRETCH_TILE:
  37. .. _class_TextureButton_constant_STRETCH_KEEP:
  38. .. _class_TextureButton_constant_STRETCH_KEEP_CENTERED:
  39. .. _class_TextureButton_constant_STRETCH_KEEP_ASPECT:
  40. .. _class_TextureButton_constant_STRETCH_KEEP_ASPECT_CENTERED:
  41. .. _class_TextureButton_constant_STRETCH_KEEP_ASPECT_COVERED:
  42. enum **StretchMode**:
  43. - **STRETCH_SCALE** = **0** --- Scale to fit the node's bounding rectangle.
  44. - **STRETCH_TILE** = **1** --- Tile inside the node's bounding rectangle.
  45. - **STRETCH_KEEP** = **2** --- The texture keeps its original size and stays in the bounding rectangle's top-left corner.
  46. - **STRETCH_KEEP_CENTERED** = **3** --- The texture keeps its original size and stays centered in the node's bounding rectangle.
  47. - **STRETCH_KEEP_ASPECT** = **4** --- Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
  48. - **STRETCH_KEEP_ASPECT_CENTERED** = **5** --- Scale the texture to fit the node's bounding rectangle, center it, and maintain its aspect ratio.
  49. - **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.
  50. Description
  51. -----------
  52. ``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 Controls.
  53. The Normal state's texture is required. Others are optional.
  54. Property Descriptions
  55. ---------------------
  56. .. _class_TextureButton_property_expand:
  57. - :ref:`bool<class_bool>` **expand**
  58. +----------+-------------------+
  59. | *Setter* | set_expand(value) |
  60. +----------+-------------------+
  61. | *Getter* | get_expand() |
  62. +----------+-------------------+
  63. 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. Default value: ``false``.
  64. ----
  65. .. _class_TextureButton_property_stretch_mode:
  66. - :ref:`StretchMode<enum_TextureButton_StretchMode>` **stretch_mode**
  67. +----------+-------------------------+
  68. | *Setter* | set_stretch_mode(value) |
  69. +----------+-------------------------+
  70. | *Getter* | get_stretch_mode() |
  71. +----------+-------------------------+
  72. 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 ``STRETCH_*`` constants. See the constants to learn more.
  73. ----
  74. .. _class_TextureButton_property_texture_click_mask:
  75. - :ref:`BitMap<class_BitMap>` **texture_click_mask**
  76. +----------+-----------------------+
  77. | *Setter* | set_click_mask(value) |
  78. +----------+-----------------------+
  79. | *Getter* | get_click_mask() |
  80. +----------+-----------------------+
  81. 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.
  82. ----
  83. .. _class_TextureButton_property_texture_disabled:
  84. - :ref:`Texture<class_Texture>` **texture_disabled**
  85. +----------+-----------------------------+
  86. | *Setter* | set_disabled_texture(value) |
  87. +----------+-----------------------------+
  88. | *Getter* | get_disabled_texture() |
  89. +----------+-----------------------------+
  90. Texture to display when the node is disabled. See :ref:`BaseButton.disabled<class_BaseButton_property_disabled>`.
  91. ----
  92. .. _class_TextureButton_property_texture_focused:
  93. - :ref:`Texture<class_Texture>` **texture_focused**
  94. +----------+----------------------------+
  95. | *Setter* | set_focused_texture(value) |
  96. +----------+----------------------------+
  97. | *Getter* | get_focused_texture() |
  98. +----------+----------------------------+
  99. Texture to display when the node has mouse or keyboard focus.
  100. ----
  101. .. _class_TextureButton_property_texture_hover:
  102. - :ref:`Texture<class_Texture>` **texture_hover**
  103. +----------+--------------------------+
  104. | *Setter* | set_hover_texture(value) |
  105. +----------+--------------------------+
  106. | *Getter* | get_hover_texture() |
  107. +----------+--------------------------+
  108. Texture to display when the mouse hovers the node.
  109. ----
  110. .. _class_TextureButton_property_texture_normal:
  111. - :ref:`Texture<class_Texture>` **texture_normal**
  112. +----------+---------------------------+
  113. | *Setter* | set_normal_texture(value) |
  114. +----------+---------------------------+
  115. | *Getter* | get_normal_texture() |
  116. +----------+---------------------------+
  117. Texture to display by default, when the node is **not** in the disabled, focused, hover or pressed state.
  118. ----
  119. .. _class_TextureButton_property_texture_pressed:
  120. - :ref:`Texture<class_Texture>` **texture_pressed**
  121. +----------+----------------------------+
  122. | *Setter* | set_pressed_texture(value) |
  123. +----------+----------------------------+
  124. | *Getter* | get_pressed_texture() |
  125. +----------+----------------------------+
  126. 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.