class_touchscreenbutton.rst 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the TouchScreenButton.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_TouchScreenButton:
  6. TouchScreenButton
  7. =================
  8. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Button for touch screen devices for gameplay use.
  10. Description
  11. -----------
  12. TouchScreenButton allows you to create on-screen buttons for touch devices. It's intended for gameplay use, such as a unit you have to touch to move. Unlike :ref:`Button<class_Button>`, TouchScreenButton supports multitouch out of the box. Several TouchScreenButtons can be pressed at the same time with touch input.
  13. This node inherits from :ref:`Node2D<class_Node2D>`. Unlike with :ref:`Control<class_Control>` nodes, you cannot set anchors on it. If you want to create menus or user interfaces, you may want to use :ref:`Button<class_Button>` nodes instead. To make button nodes react to touch events, you can enable the Emulate Mouse option in the Project Settings.
  14. You can configure TouchScreenButton to be visible only on touch devices, helping you develop your game both for desktop and mobile devices.
  15. Properties
  16. ----------
  17. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  18. | :ref:`String<class_String>` | :ref:`action<class_TouchScreenButton_property_action>` | ``""`` |
  19. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  20. | :ref:`BitMap<class_BitMap>` | :ref:`bitmask<class_TouchScreenButton_property_bitmask>` | |
  21. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  22. | :ref:`Texture<class_Texture>` | :ref:`normal<class_TouchScreenButton_property_normal>` | |
  23. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  24. | :ref:`bool<class_bool>` | :ref:`passby_press<class_TouchScreenButton_property_passby_press>` | ``false`` |
  25. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  26. | :ref:`Texture<class_Texture>` | :ref:`pressed<class_TouchScreenButton_property_pressed>` | |
  27. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  28. | :ref:`Shape2D<class_Shape2D>` | :ref:`shape<class_TouchScreenButton_property_shape>` | |
  29. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  30. | :ref:`bool<class_bool>` | :ref:`shape_centered<class_TouchScreenButton_property_shape_centered>` | ``true`` |
  31. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  32. | :ref:`bool<class_bool>` | :ref:`shape_visible<class_TouchScreenButton_property_shape_visible>` | ``true`` |
  33. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  34. | :ref:`VisibilityMode<enum_TouchScreenButton_VisibilityMode>` | :ref:`visibility_mode<class_TouchScreenButton_property_visibility_mode>` | ``0`` |
  35. +--------------------------------------------------------------+--------------------------------------------------------------------------+-----------+
  36. Methods
  37. -------
  38. +-------------------------+----------------------------------------------------------------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`is_pressed<class_TouchScreenButton_method_is_pressed>` **(** **)** |const| |
  40. +-------------------------+----------------------------------------------------------------------------------+
  41. Signals
  42. -------
  43. .. _class_TouchScreenButton_signal_pressed:
  44. - **pressed** **(** **)**
  45. Emitted when the button is pressed (down).
  46. ----
  47. .. _class_TouchScreenButton_signal_released:
  48. - **released** **(** **)**
  49. Emitted when the button is released (up).
  50. Enumerations
  51. ------------
  52. .. _enum_TouchScreenButton_VisibilityMode:
  53. .. _class_TouchScreenButton_constant_VISIBILITY_ALWAYS:
  54. .. _class_TouchScreenButton_constant_VISIBILITY_TOUCHSCREEN_ONLY:
  55. enum **VisibilityMode**:
  56. - **VISIBILITY_ALWAYS** = **0** --- Always visible.
  57. - **VISIBILITY_TOUCHSCREEN_ONLY** = **1** --- Visible on touch screens only.
  58. Property Descriptions
  59. ---------------------
  60. .. _class_TouchScreenButton_property_action:
  61. - :ref:`String<class_String>` **action**
  62. +-----------+-------------------+
  63. | *Default* | ``""`` |
  64. +-----------+-------------------+
  65. | *Setter* | set_action(value) |
  66. +-----------+-------------------+
  67. | *Getter* | get_action() |
  68. +-----------+-------------------+
  69. The button's action. Actions can be handled with :ref:`InputEventAction<class_InputEventAction>`.
  70. ----
  71. .. _class_TouchScreenButton_property_bitmask:
  72. - :ref:`BitMap<class_BitMap>` **bitmask**
  73. +----------+--------------------+
  74. | *Setter* | set_bitmask(value) |
  75. +----------+--------------------+
  76. | *Getter* | get_bitmask() |
  77. +----------+--------------------+
  78. The button's bitmask.
  79. ----
  80. .. _class_TouchScreenButton_property_normal:
  81. - :ref:`Texture<class_Texture>` **normal**
  82. +----------+--------------------+
  83. | *Setter* | set_texture(value) |
  84. +----------+--------------------+
  85. | *Getter* | get_texture() |
  86. +----------+--------------------+
  87. The button's texture for the normal state.
  88. ----
  89. .. _class_TouchScreenButton_property_passby_press:
  90. - :ref:`bool<class_bool>` **passby_press**
  91. +-----------+---------------------------+
  92. | *Default* | ``false`` |
  93. +-----------+---------------------------+
  94. | *Setter* | set_passby_press(value) |
  95. +-----------+---------------------------+
  96. | *Getter* | is_passby_press_enabled() |
  97. +-----------+---------------------------+
  98. If ``true``, the :ref:`pressed<class_TouchScreenButton_signal_pressed>` and :ref:`released<class_TouchScreenButton_signal_released>` signals are emitted whenever a pressed finger goes in and out of the button, even if the pressure started outside the active area of the button.
  99. **Note:** This is a "pass-by" (not "bypass") press mode.
  100. ----
  101. .. _class_TouchScreenButton_property_pressed:
  102. - :ref:`Texture<class_Texture>` **pressed**
  103. +----------+----------------------------+
  104. | *Setter* | set_texture_pressed(value) |
  105. +----------+----------------------------+
  106. | *Getter* | get_texture_pressed() |
  107. +----------+----------------------------+
  108. The button's texture for the pressed state.
  109. ----
  110. .. _class_TouchScreenButton_property_shape:
  111. - :ref:`Shape2D<class_Shape2D>` **shape**
  112. +----------+------------------+
  113. | *Setter* | set_shape(value) |
  114. +----------+------------------+
  115. | *Getter* | get_shape() |
  116. +----------+------------------+
  117. The button's shape.
  118. ----
  119. .. _class_TouchScreenButton_property_shape_centered:
  120. - :ref:`bool<class_bool>` **shape_centered**
  121. +-----------+---------------------------+
  122. | *Default* | ``true`` |
  123. +-----------+---------------------------+
  124. | *Setter* | set_shape_centered(value) |
  125. +-----------+---------------------------+
  126. | *Getter* | is_shape_centered() |
  127. +-----------+---------------------------+
  128. If ``true``, the button's shape is centered in the provided texture. If no texture is used, this property has no effect.
  129. ----
  130. .. _class_TouchScreenButton_property_shape_visible:
  131. - :ref:`bool<class_bool>` **shape_visible**
  132. +-----------+--------------------------+
  133. | *Default* | ``true`` |
  134. +-----------+--------------------------+
  135. | *Setter* | set_shape_visible(value) |
  136. +-----------+--------------------------+
  137. | *Getter* | is_shape_visible() |
  138. +-----------+--------------------------+
  139. If ``true``, the button's shape is visible.
  140. ----
  141. .. _class_TouchScreenButton_property_visibility_mode:
  142. - :ref:`VisibilityMode<enum_TouchScreenButton_VisibilityMode>` **visibility_mode**
  143. +-----------+----------------------------+
  144. | *Default* | ``0`` |
  145. +-----------+----------------------------+
  146. | *Setter* | set_visibility_mode(value) |
  147. +-----------+----------------------------+
  148. | *Getter* | get_visibility_mode() |
  149. +-----------+----------------------------+
  150. The button's visibility mode. See :ref:`VisibilityMode<enum_TouchScreenButton_VisibilityMode>` for possible values.
  151. Method Descriptions
  152. -------------------
  153. .. _class_TouchScreenButton_method_is_pressed:
  154. - :ref:`bool<class_bool>` **is_pressed** **(** **)** |const|
  155. Returns ``true`` if this button is currently pressed.
  156. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  157. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  158. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`