class_inputevent.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 InputEvent.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_InputEvent:
  6. InputEvent
  7. ==========
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`InputEventAction<class_InputEventAction>`, :ref:`InputEventJoypadButton<class_InputEventJoypadButton>`, :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>`, :ref:`InputEventMIDI<class_InputEventMIDI>`, :ref:`InputEventScreenDrag<class_InputEventScreenDrag>`, :ref:`InputEventScreenTouch<class_InputEventScreenTouch>`, :ref:`InputEventWithModifiers<class_InputEventWithModifiers>`
  10. Generic input event.
  11. Description
  12. -----------
  13. Base class of all sort of input event. See :ref:`Node._input<class_Node_method__input>`.
  14. Tutorials
  15. ---------
  16. - :doc:`../tutorials/inputs/inputevent`
  17. - :doc:`../tutorials/2d/2d_transforms`
  18. Properties
  19. ----------
  20. +-----------------------+-------------------------------------------------+-------+
  21. | :ref:`int<class_int>` | :ref:`device<class_InputEvent_property_device>` | ``0`` |
  22. +-----------------------+-------------------------------------------------+-------+
  23. Methods
  24. -------
  25. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`accumulate<class_InputEvent_method_accumulate>` **(** :ref:`InputEvent<class_InputEvent>` with_event **)** |
  27. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`String<class_String>` | :ref:`as_text<class_InputEvent_method_as_text>` **(** **)** |const| |
  29. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`get_action_strength<class_InputEvent_method_get_action_strength>` **(** :ref:`String<class_String>` action **)** |const| |
  31. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`is_action<class_InputEvent_method_is_action>` **(** :ref:`String<class_String>` action **)** |const| |
  33. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`bool<class_bool>` | :ref:`is_action_pressed<class_InputEvent_method_is_action_pressed>` **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` allow_echo=false **)** |const| |
  35. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`is_action_released<class_InputEvent_method_is_action_released>` **(** :ref:`String<class_String>` action **)** |const| |
  37. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`is_action_type<class_InputEvent_method_is_action_type>` **(** **)** |const| |
  39. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`bool<class_bool>` | :ref:`is_echo<class_InputEvent_method_is_echo>` **(** **)** |const| |
  41. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`is_pressed<class_InputEvent_method_is_pressed>` **(** **)** |const| |
  43. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`shortcut_match<class_InputEvent_method_shortcut_match>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |const| |
  45. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :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| |
  47. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. Property Descriptions
  49. ---------------------
  50. .. _class_InputEvent_property_device:
  51. - :ref:`int<class_int>` **device**
  52. +-----------+-------------------+
  53. | *Default* | ``0`` |
  54. +-----------+-------------------+
  55. | *Setter* | set_device(value) |
  56. +-----------+-------------------+
  57. | *Getter* | get_device() |
  58. +-----------+-------------------+
  59. The event's device ID.
  60. **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.
  61. Method Descriptions
  62. -------------------
  63. .. _class_InputEvent_method_accumulate:
  64. - :ref:`bool<class_bool>` **accumulate** **(** :ref:`InputEvent<class_InputEvent>` with_event **)**
  65. Returns ``true`` if the given input event and this input event can be added together (only for events of type :ref:`InputEventMouseMotion<class_InputEventMouseMotion>`).
  66. 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.
  67. ----
  68. .. _class_InputEvent_method_as_text:
  69. - :ref:`String<class_String>` **as_text** **(** **)** |const|
  70. Returns a :ref:`String<class_String>` representation of the event.
  71. ----
  72. .. _class_InputEvent_method_get_action_strength:
  73. - :ref:`float<class_float>` **get_action_strength** **(** :ref:`String<class_String>` action **)** |const|
  74. 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>`.
  75. ----
  76. .. _class_InputEvent_method_is_action:
  77. - :ref:`bool<class_bool>` **is_action** **(** :ref:`String<class_String>` action **)** |const|
  78. Returns ``true`` if this input event matches a pre-defined action of any type.
  79. ----
  80. .. _class_InputEvent_method_is_action_pressed:
  81. - :ref:`bool<class_bool>` **is_action_pressed** **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` allow_echo=false **)** |const|
  82. 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>`.
  83. ----
  84. .. _class_InputEvent_method_is_action_released:
  85. - :ref:`bool<class_bool>` **is_action_released** **(** :ref:`String<class_String>` action **)** |const|
  86. 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>`.
  87. ----
  88. .. _class_InputEvent_method_is_action_type:
  89. - :ref:`bool<class_bool>` **is_action_type** **(** **)** |const|
  90. Returns ``true`` if this input event's type is one that can be assigned to an input action.
  91. ----
  92. .. _class_InputEvent_method_is_echo:
  93. - :ref:`bool<class_bool>` **is_echo** **(** **)** |const|
  94. Returns ``true`` if this input event is an echo event (only for events of type :ref:`InputEventKey<class_InputEventKey>`).
  95. ----
  96. .. _class_InputEvent_method_is_pressed:
  97. - :ref:`bool<class_bool>` **is_pressed** **(** **)** |const|
  98. Returns ``true`` if this input event is pressed. Not relevant for events of type :ref:`InputEventMouseMotion<class_InputEventMouseMotion>` or :ref:`InputEventScreenDrag<class_InputEventScreenDrag>`.
  99. ----
  100. .. _class_InputEvent_method_shortcut_match:
  101. - :ref:`bool<class_bool>` **shortcut_match** **(** :ref:`InputEvent<class_InputEvent>` event **)** |const|
  102. Returns ``true`` if the given input event is checking for the same key (:ref:`InputEventKey<class_InputEventKey>`), button (:ref:`InputEventJoypadButton<class_InputEventJoypadButton>`) or action (:ref:`InputEventAction<class_InputEventAction>`).
  103. ----
  104. .. _class_InputEvent_method_xformed_by:
  105. - :ref:`InputEvent<class_InputEvent>` **xformed_by** **(** :ref:`Transform2D<class_Transform2D>` xform, :ref:`Vector2<class_Vector2>` local_ofs=Vector2( 0, 0 ) **)** |const|
  106. 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>`.
  107. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  108. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  109. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`