class_texturebutton.rst 8.0 KB

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