class_inputevent.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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/InputEvent.xml.
  6. .. _class_InputEvent:
  7. InputEvent
  8. ==========
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`InputEventAction<class_InputEventAction>`, :ref:`InputEventFromWindow<class_InputEventFromWindow>`, :ref:`InputEventJoypadButton<class_InputEventJoypadButton>`, :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>`, :ref:`InputEventMIDI<class_InputEventMIDI>`, :ref:`InputEventShortcut<class_InputEventShortcut>`
  11. Generic input event.
  12. Description
  13. -----------
  14. Base class of all sort of input event. See :ref:`Node._input<class_Node_method__input>`.
  15. Tutorials
  16. ---------
  17. - :doc:`InputEvent <../tutorials/inputs/inputevent>`
  18. - :doc:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>`
  19. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  20. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
  21. Properties
  22. ----------
  23. +-----------------------+-------------------------------------------------+-------+
  24. | :ref:`int<class_int>` | :ref:`device<class_InputEvent_property_device>` | ``0`` |
  25. +-----------------------+-------------------------------------------------+-------+
  26. Methods
  27. -------
  28. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`accumulate<class_InputEvent_method_accumulate>` **(** :ref:`InputEvent<class_InputEvent>` with_event **)** |
  30. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`String<class_String>` | :ref:`as_text<class_InputEvent_method_as_text>` **(** **)** |const| |
  32. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`get_action_strength<class_InputEvent_method_get_action_strength>` **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  34. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`is_action<class_InputEvent_method_is_action>` **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  36. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`is_action_pressed<class_InputEvent_method_is_action_pressed>` **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` allow_echo=false, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  38. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`is_action_released<class_InputEvent_method_is_action_released>` **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  40. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`is_action_type<class_InputEvent_method_is_action_type>` **(** **)** |const| |
  42. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`is_echo<class_InputEvent_method_is_echo>` **(** **)** |const| |
  44. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`is_match<class_InputEvent_method_is_match>` **(** :ref:`InputEvent<class_InputEvent>` event, :ref:`bool<class_bool>` exact_match=true **)** |const| |
  46. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`is_pressed<class_InputEvent_method_is_pressed>` **(** **)** |const| |
  48. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`InputEvent<class_InputEvent>` | :ref:`xformed_by<class_InputEvent_method_xformed_by>` **(** :ref:`Transform2D<class_Transform2D>` xform, :ref:`Vector2<class_Vector2>` local_ofs=Vector2(0, 0) **)** |const| |
  50. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. Property Descriptions
  52. ---------------------
  53. .. _class_InputEvent_property_device:
  54. - :ref:`int<class_int>` **device**
  55. +-----------+-------------------+
  56. | *Default* | ``0`` |
  57. +-----------+-------------------+
  58. | *Setter* | set_device(value) |
  59. +-----------+-------------------+
  60. | *Getter* | get_device() |
  61. +-----------+-------------------+
  62. The event's device ID.
  63. \ **Note:** This device ID will always be ``-1`` for emulated mouse input from a touchscreen. This can be used to distinguish emulated mouse input from physical mouse input.
  64. Method Descriptions
  65. -------------------
  66. .. _class_InputEvent_method_accumulate:
  67. - :ref:`bool<class_bool>` **accumulate** **(** :ref:`InputEvent<class_InputEvent>` with_event **)**
  68. Returns ``true`` if the given input event and this input event can be added together (only for events of type :ref:`InputEventMouseMotion<class_InputEventMouseMotion>`).
  69. The given input event's position, global position and speed will be copied. The resulting ``relative`` is a sum of both events. Both events' modifiers have to be identical.
  70. ----
  71. .. _class_InputEvent_method_as_text:
  72. - :ref:`String<class_String>` **as_text** **(** **)** |const|
  73. Returns a :ref:`String<class_String>` representation of the event.
  74. ----
  75. .. _class_InputEvent_method_get_action_strength:
  76. - :ref:`float<class_float>` **get_action_strength** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  77. Returns a value between 0.0 and 1.0 depending on the given actions' state. Useful for getting the value of events of type :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>`.
  78. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  79. ----
  80. .. _class_InputEvent_method_is_action:
  81. - :ref:`bool<class_bool>` **is_action** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  82. Returns ``true`` if this input event matches a pre-defined action of any type.
  83. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  84. ----
  85. .. _class_InputEvent_method_is_action_pressed:
  86. - :ref:`bool<class_bool>` **is_action_pressed** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` allow_echo=false, :ref:`bool<class_bool>` exact_match=false **)** |const|
  87. Returns ``true`` if the given action is being pressed (and is not an echo event for :ref:`InputEventKey<class_InputEventKey>` events, unless ``allow_echo`` is ``true``). Not relevant for events of type :ref:`InputEventMouseMotion<class_InputEventMouseMotion>` or :ref:`InputEventScreenDrag<class_InputEventScreenDrag>`.
  88. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  89. \ **Note:** Due to keyboard ghosting, :ref:`is_action_pressed<class_InputEvent_method_is_action_pressed>` may return ``false`` even if one of the action's keys is pressed. See `Input examples <../tutorials/inputs/input_examples.html#keyboard-events>`__ in the documentation for more information.
  90. ----
  91. .. _class_InputEvent_method_is_action_released:
  92. - :ref:`bool<class_bool>` **is_action_released** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  93. Returns ``true`` if the given action is released (i.e. not pressed). Not relevant for events of type :ref:`InputEventMouseMotion<class_InputEventMouseMotion>` or :ref:`InputEventScreenDrag<class_InputEventScreenDrag>`.
  94. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  95. ----
  96. .. _class_InputEvent_method_is_action_type:
  97. - :ref:`bool<class_bool>` **is_action_type** **(** **)** |const|
  98. Returns ``true`` if this input event's type is one that can be assigned to an input action.
  99. ----
  100. .. _class_InputEvent_method_is_echo:
  101. - :ref:`bool<class_bool>` **is_echo** **(** **)** |const|
  102. Returns ``true`` if this input event is an echo event (only for events of type :ref:`InputEventKey<class_InputEventKey>`).
  103. ----
  104. .. _class_InputEvent_method_is_match:
  105. - :ref:`bool<class_bool>` **is_match** **(** :ref:`InputEvent<class_InputEvent>` event, :ref:`bool<class_bool>` exact_match=true **)** |const|
  106. Returns ``true`` if the specified ``event`` matches this event. Only valid for action events i.e key (:ref:`InputEventKey<class_InputEventKey>`), button (:ref:`InputEventMouseButton<class_InputEventMouseButton>` or :ref:`InputEventJoypadButton<class_InputEventJoypadButton>`), axis :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` or action (:ref:`InputEventAction<class_InputEventAction>`) events.
  107. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  108. ----
  109. .. _class_InputEvent_method_is_pressed:
  110. - :ref:`bool<class_bool>` **is_pressed** **(** **)** |const|
  111. Returns ``true`` if this input event is pressed. Not relevant for events of type :ref:`InputEventMouseMotion<class_InputEventMouseMotion>` or :ref:`InputEventScreenDrag<class_InputEventScreenDrag>`.
  112. \ **Note:** Due to keyboard ghosting, :ref:`is_pressed<class_InputEvent_method_is_pressed>` may return ``false`` even if one of the action's keys is pressed. See `Input examples <../tutorials/inputs/input_examples.html#keyboard-events>`__ in the documentation for more information.
  113. ----
  114. .. _class_InputEvent_method_xformed_by:
  115. - :ref:`InputEvent<class_InputEvent>` **xformed_by** **(** :ref:`Transform2D<class_Transform2D>` xform, :ref:`Vector2<class_Vector2>` local_ofs=Vector2(0, 0) **)** |const|
  116. Returns a copy of the given input event which has been offset by ``local_ofs`` and transformed by ``xform``. Relevant for events of type :ref:`InputEventMouseButton<class_InputEventMouseButton>`, :ref:`InputEventMouseMotion<class_InputEventMouseMotion>`, :ref:`InputEventScreenTouch<class_InputEventScreenTouch>`, :ref:`InputEventScreenDrag<class_InputEventScreenDrag>`, :ref:`InputEventMagnifyGesture<class_InputEventMagnifyGesture>` and :ref:`InputEventPanGesture<class_InputEventPanGesture>`.
  117. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  118. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  119. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  120. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  121. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  122. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`