:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from GUT Plugin sources. .. Generator: documentation/godot_make_rst.py. .. _class_GutInputSender: GutInputSender ============== **Inherits:** `RefCounted `_ The GutInputSender class. It sends input to places. .. rst-class:: classref-introduction-group Description ----------- GUT Wiki: `https://gut.readthedocs.io `__\ See `Mocking-Input <../Mocking-Input.html>`__ for examples. This class can be used to send ``InputEvent*`` events to various objects. It also allows you to script out a series of inputs and play them back in real time. You could use it to: - Verify that jump height depends on how long the jump button is pressed. - Double tap a direction performs a dash. - Down, Down-Forward, Forward + punch throws a fireball. And much much more. As of 9.3.1 you can use ``GutInputSender`` instead of ``InputSender``. It's the same thing, but ``GutInputSender`` is a ``class_name`` so you may have less warnings and auto-complete will work. \ **Warning**\ If you move the Godot window to a different monitor while tests are running it can cause input tests to fail. `This issue `__ has more details. .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +--------------------------------------------------------------------------------+-------------------------------------------------------------+-----------+ | `Variant `_ | :ref:`mouse_warp` | ``false`` | +--------------------------------------------------------------------------------+-------------------------------------------------------------+-----------+ | `Variant `_ | :ref:`draw_mouse` | ``true`` | +--------------------------------------------------------------------------------+-------------------------------------------------------------+-----------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_init`\ (\ r = null\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`action_down`\ (\ which, strength = 1.0\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`action_up`\ (\ which, strength = 1.0\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_receiver`\ (\ obj\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`clear`\ (\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`get_auto_flush_input`\ (\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`get_receivers`\ (\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`hold_for`\ (\ duration\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`hold_frames`\ (\ duration\: `int `_\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`hold_seconds`\ (\ duration\: `float `_\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`is_action_pressed`\ (\ which\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`is_idle`\ (\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`is_key_pressed`\ (\ which\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`is_mouse_button_pressed`\ (\ which\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`key_down`\ (\ which\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`key_echo`\ (\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`key_up`\ (\ which\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`mouse_double_click`\ (\ position = null, global_position = null\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`mouse_left_button_down`\ (\ position = null, global_position = null\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`mouse_left_button_up`\ (\ position = null, global_position = null\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`mouse_left_click_at`\ (\ where, duration = "5f"\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`mouse_motion`\ (\ position, global_position = null\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`mouse_relative_motion`\ (\ offset, speed = Vector2(0, 0)\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`mouse_right_button_down`\ (\ position = null, global_position = null\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`mouse_right_button_up`\ (\ position = null, global_position = null\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`mouse_set_position`\ (\ position, global_position = null\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`release_all`\ (\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`send_event`\ (\ event\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_auto_flush_input`\ (\ val\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`wait`\ (\ t\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`wait_frames`\ (\ num_frames\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Variant `_ | :ref:`wait_secs`\ (\ num_secs\ ) | +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Signals ------- .. _class_GutInputSender_signal_idle: .. rst-class:: classref-signal **idle**\ (\ ) :ref:`🔗` Emitted when all events in the input queue have been sent. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Constants --------- .. _class_GutInputSender_constant_INPUT_WARN: .. rst-class:: classref-constant **INPUT_WARN** = ``"If using Input as a reciever it will not respond to *_down events until a *_up event is recieved. Call the appropriate *_up event or use hold_for(...) to automatically release after some duration."`` :ref:`🔗` Local reference to the GutInputFactory static class .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_GutInputSender_property_mouse_warp: .. rst-class:: classref-property `Variant `_ **mouse_warp** = ``false`` :ref:`🔗` Warp mouse when sending InputEventMouse\* events .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_property_draw_mouse: .. rst-class:: classref-property `Variant `_ **draw_mouse** = ``true`` :ref:`🔗` Draw mouse position cross hairs. Useful to see where the mouse is at when not using :ref:`mouse_warp` .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_GutInputSender_private_method__init: .. rst-class:: classref-method |void| **_init**\ (\ r = null\ ) :ref:`🔗` Accepts a single optional receiver. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_add_receiver: .. rst-class:: classref-method |void| **add_receiver**\ (\ obj\ ) :ref:`🔗` Add an object to receive input events. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_get_receivers: .. rst-class:: classref-method `Variant `_ **get_receivers**\ (\ ) :ref:`🔗` Returns the receivers that have been added. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_is_idle: .. rst-class:: classref-method `Variant `_ **is_idle**\ (\ ) :ref:`🔗` Returns true if the input queue has items to be processed, false if not. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_is_key_pressed: .. rst-class:: classref-method `Variant `_ **is_key_pressed**\ (\ which\ ) :ref:`🔗` .. container:: contribute No description .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_is_action_pressed: .. rst-class:: classref-method `Variant `_ **is_action_pressed**\ (\ which\ ) :ref:`🔗` .. container:: contribute No description .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_is_mouse_button_pressed: .. rst-class:: classref-method `Variant `_ **is_mouse_button_pressed**\ (\ which\ ) :ref:`🔗` .. container:: contribute No description .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_get_auto_flush_input: .. rst-class:: classref-method `Variant `_ **get_auto_flush_input**\ (\ ) :ref:`🔗` Get the value of :ref:`set_auto_flush_input`. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_set_auto_flush_input: .. rst-class:: classref-method |void| **set_auto_flush_input**\ (\ val\ ) :ref:`🔗` Enable/Disable auto flushing of input. When enabled the **GutInputSender** will call ``Input.flush_buffered_events`` after each event is sent. See the "use_accumulated_input" section in `Mocking-Input <../Mocking-Input.html>`__ for more information. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_wait: .. rst-class:: classref-method `Variant `_ **wait**\ (\ t\ ) :ref:`🔗` Adds a delay between the last input queue item added and any queue item added next. By default this will wait ``t`` seconds. You can specify a number of frames to wait by passing a string composed of a number and "f". For example ``wait("5f")`` will wait 5 frames. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_clear: .. rst-class:: classref-method |void| **clear**\ (\ ) :ref:`🔗` Clears the input queue and any state such as the last event sent and any pressed actions/buttons. Does not clear the list of receivers. This should be done between each test when the **GutInputSender** is a class level variable so that state does not leak between tests. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_key_up: .. rst-class:: classref-method `Variant `_ **key_up**\ (\ which\ ) :ref:`🔗` Sends a `InputEventKey `_ event with ``pressed = false``. ``which`` can be a character or a ``KEY_*`` constant. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_key_down: .. rst-class:: classref-method `Variant `_ **key_down**\ (\ which\ ) :ref:`🔗` Sends a `InputEventKey `_ event with ``pressed = true``. ``which`` can be a character or a ``KEY_*`` constant. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_key_echo: .. rst-class:: classref-method `Variant `_ **key_echo**\ (\ ) :ref:`🔗` Sends an echo `InputEventKey `_ event of the last key event. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_action_up: .. rst-class:: classref-method `Variant `_ **action_up**\ (\ which, strength = 1.0\ ) :ref:`🔗` Sends a "action up" `InputEventAction `_ instance. ``which`` is the name of the action defined in the Key Map. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_action_down: .. rst-class:: classref-method `Variant `_ **action_down**\ (\ which, strength = 1.0\ ) :ref:`🔗` Sends a "action down" `InputEventAction `_ instance. ``which`` is the name of the action defined in the Key Map. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_mouse_left_button_down: .. rst-class:: classref-method `Variant `_ **mouse_left_button_down**\ (\ position = null, global_position = null\ ) :ref:`🔗` Sends a "button down" `InputEventMouseButton `_ for the left mouse button. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_mouse_left_button_up: .. rst-class:: classref-method `Variant `_ **mouse_left_button_up**\ (\ position = null, global_position = null\ ) :ref:`🔗` Sends a "button up" `InputEventMouseButton `_ for the left mouse button. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_mouse_double_click: .. rst-class:: classref-method `Variant `_ **mouse_double_click**\ (\ position = null, global_position = null\ ) :ref:`🔗` Sends a "double click" `InputEventMouseButton `_ for the left mouse button. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_mouse_right_button_down: .. rst-class:: classref-method `Variant `_ **mouse_right_button_down**\ (\ position = null, global_position = null\ ) :ref:`🔗` Sends a "button down" `InputEventMouseButton `_ for the right mouse button. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_mouse_right_button_up: .. rst-class:: classref-method `Variant `_ **mouse_right_button_up**\ (\ position = null, global_position = null\ ) :ref:`🔗` Sends a "button up" `InputEventMouseButton `_ for the right mouse button. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_mouse_motion: .. rst-class:: classref-method `Variant `_ **mouse_motion**\ (\ position, global_position = null\ ) :ref:`🔗` Sends a `InputEventMouseMotion `_ to move the mouse the specified positions. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_mouse_relative_motion: .. rst-class:: classref-method `Variant `_ **mouse_relative_motion**\ (\ offset, speed = Vector2(0, 0)\ ) :ref:`🔗` Sends a `InputEventMouseMotion `_ that moves the mouse ``offset`` from the last :ref:`mouse_motion` or :ref:`mouse_set_position` call. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_mouse_set_position: .. rst-class:: classref-method `Variant `_ **mouse_set_position**\ (\ position, global_position = null\ ) :ref:`🔗` Sets the mouse's position. This does not send an event. This position will be used for the next call to :ref:`mouse_relative_motion`. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_mouse_left_click_at: .. rst-class:: classref-method `Variant `_ **mouse_left_click_at**\ (\ where, duration = "5f"\ ) :ref:`🔗` Performs a left click at the given position. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_send_event: .. rst-class:: classref-method `Variant `_ **send_event**\ (\ event\ ) :ref:`🔗` Create your own event and use this to send it to all receivers. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_release_all: .. rst-class:: classref-method `Variant `_ **release_all**\ (\ ) :ref:`🔗` Releases all `InputEventKey `_, `InputEventAction `_, and `InputEventMouseButton `_ events that have passed through this instance. These events could have been generated via the various ``_down`` methods or passed to :ref:`send_event`. This will send the "release" event (``pressed = false``) to all receivers. This should be done between each test when using `Input` as a receiver. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_wait_frames: .. rst-class:: classref-method `Variant `_ **wait_frames**\ (\ num_frames\ ) :ref:`🔗` Same as :ref:`wait` but only accepts a number of frames to wait. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_wait_secs: .. rst-class:: classref-method `Variant `_ **wait_secs**\ (\ num_secs\ ) :ref:`🔗` Same as :ref:`wait` but only accepts a number of seconds to wait. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_hold_for: .. rst-class:: classref-method `Variant `_ **hold_for**\ (\ duration\ ) :ref:`🔗` This is a special :ref:`wait` that will emit the previous input queue item with ``pressed = false`` after a delay. If you pass a number then it will wait that many seconds. You can also use the `"4f"` format to wait a specific number of frames. For example ``sender.action_down('jump').hold_for("10f")`` will cause two `InputEventAction `_ instances to be sent. The "jump-down" event from :ref:`action_down` and then a "jump-up" event after 10 frames. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_hold_frames: .. rst-class:: classref-method `Variant `_ **hold_frames**\ (\ duration\: `int `_\ ) :ref:`🔗` Same as :ref:`hold_for` but specifically holds for a number of physics frames. .. rst-class:: classref-item-separator ---- .. _class_GutInputSender_method_hold_seconds: .. rst-class:: classref-method `Variant `_ **hold_seconds**\ (\ duration\: `float `_\ ) :ref:`🔗` Same as :ref:`hold_for` but specifically holds for a number of seconds. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`