InputEvent.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="InputEvent" inherits="Resource" version="3.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Generic input event.
  5. </brief_description>
  6. <description>
  7. Base class of all sort of input event. See [method Node._input].
  8. </description>
  9. <tutorials>
  10. <link title="InputEvent">$DOCS_URL/tutorials/inputs/inputevent.html</link>
  11. <link title="Viewport and canvas transforms">$DOCS_URL/tutorials/2d/2d_transforms.html</link>
  12. <link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/515</link>
  13. <link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/676</link>
  14. </tutorials>
  15. <methods>
  16. <method name="accumulate">
  17. <return type="bool" />
  18. <argument index="0" name="with_event" type="InputEvent" />
  19. <description>
  20. Returns [code]true[/code] if the given input event and this input event can be added together (only for events of type [InputEventMouseMotion]).
  21. The given input event's position, global position and speed will be copied. The resulting [code]relative[/code] is a sum of both events. Both events' modifiers have to be identical.
  22. </description>
  23. </method>
  24. <method name="as_text" qualifiers="const">
  25. <return type="String" />
  26. <description>
  27. Returns a [String] representation of the event.
  28. </description>
  29. </method>
  30. <method name="get_action_strength" qualifiers="const">
  31. <return type="float" />
  32. <argument index="0" name="action" type="String" />
  33. <argument index="1" name="exact_match" type="bool" default="false" />
  34. <description>
  35. Returns a value between 0.0 and 1.0 depending on the given actions' state. Useful for getting the value of events of type [InputEventJoypadMotion].
  36. If [code]exact_match[/code] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events.
  37. </description>
  38. </method>
  39. <method name="is_action" qualifiers="const">
  40. <return type="bool" />
  41. <argument index="0" name="action" type="String" />
  42. <argument index="1" name="exact_match" type="bool" default="false" />
  43. <description>
  44. Returns [code]true[/code] if this input event matches a pre-defined action of any type.
  45. If [code]exact_match[/code] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events.
  46. </description>
  47. </method>
  48. <method name="is_action_pressed" qualifiers="const">
  49. <return type="bool" />
  50. <argument index="0" name="action" type="String" />
  51. <argument index="1" name="allow_echo" type="bool" default="false" />
  52. <argument index="2" name="exact_match" type="bool" default="false" />
  53. <description>
  54. Returns [code]true[/code] if the given action is being pressed (and is not an echo event for [InputEventKey] events, unless [code]allow_echo[/code] is [code]true[/code]). Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag].
  55. If [code]exact_match[/code] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events.
  56. [b]Note:[/b] Due to keyboard ghosting, [method is_action_pressed] may return [code]false[/code] even if one of the action's keys is pressed. See [url=$DOCS_URL/tutorials/inputs/input_examples.html#keyboard-events]Input examples[/url] in the documentation for more information.
  57. </description>
  58. </method>
  59. <method name="is_action_released" qualifiers="const">
  60. <return type="bool" />
  61. <argument index="0" name="action" type="String" />
  62. <argument index="1" name="exact_match" type="bool" default="false" />
  63. <description>
  64. Returns [code]true[/code] if the given action is released (i.e. not pressed). Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag].
  65. If [code]exact_match[/code] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events.
  66. </description>
  67. </method>
  68. <method name="is_action_type" qualifiers="const">
  69. <return type="bool" />
  70. <description>
  71. Returns [code]true[/code] if this input event's type is one that can be assigned to an input action.
  72. </description>
  73. </method>
  74. <method name="is_canceled" qualifiers="const">
  75. <return type="bool" />
  76. <description>
  77. Returns [code]true[/code] if this input event has been canceled.
  78. </description>
  79. </method>
  80. <method name="is_echo" qualifiers="const">
  81. <return type="bool" />
  82. <description>
  83. Returns [code]true[/code] if this input event is an echo event (only for events of type [InputEventKey]).
  84. </description>
  85. </method>
  86. <method name="is_pressed" qualifiers="const">
  87. <return type="bool" />
  88. <description>
  89. Returns [code]true[/code] if this input event is pressed. Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag].
  90. [b]Note:[/b] Due to keyboard ghosting, [method is_action_pressed] may return [code]false[/code] even if one of the action's keys is pressed. See [url=$DOCS_URL/tutorials/inputs/input_examples.html#keyboard-events]Input examples[/url] in the documentation for more information.
  91. </description>
  92. </method>
  93. <method name="is_released" qualifiers="const">
  94. <return type="bool" />
  95. <description>
  96. Returns [code]true[/code] if this input event is released. Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag].
  97. </description>
  98. </method>
  99. <method name="shortcut_match" qualifiers="const">
  100. <return type="bool" />
  101. <argument index="0" name="event" type="InputEvent" />
  102. <argument index="1" name="exact_match" type="bool" default="true" />
  103. <description>
  104. Returns [code]true[/code] if the specified [code]event[/code] matches this event. Only valid for action events i.e key ([InputEventKey]), button ([InputEventMouseButton] or [InputEventJoypadButton]), axis [InputEventJoypadMotion] or action ([InputEventAction]) events.
  105. If [code]exact_match[/code] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events.
  106. </description>
  107. </method>
  108. <method name="xformed_by" qualifiers="const">
  109. <return type="InputEvent" />
  110. <argument index="0" name="xform" type="Transform2D" />
  111. <argument index="1" name="local_ofs" type="Vector2" default="Vector2( 0, 0 )" />
  112. <description>
  113. Returns a copy of the given input event which has been offset by [code]local_ofs[/code] and transformed by [code]xform[/code]. Relevant for events of type [InputEventMouseButton], [InputEventMouseMotion], [InputEventScreenTouch], [InputEventScreenDrag], [InputEventMagnifyGesture] and [InputEventPanGesture].
  114. </description>
  115. </method>
  116. </methods>
  117. <members>
  118. <member name="device" type="int" setter="set_device" getter="get_device" default="0">
  119. The event's device ID.
  120. [b]Note:[/b] This device ID will always be [code]-1[/code] for emulated mouse input from a touchscreen. This can be used to distinguish emulated mouse input from physical mouse input.
  121. </member>
  122. </members>
  123. <constants>
  124. </constants>
  125. </class>