Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

InputEvent

Eredita: Resource < RefCounted < Object

Ereditato da: InputEventAction, InputEventFromWindow, InputEventJoypadButton, InputEventJoypadMotion, InputEventMIDI, InputEventShortcut

Classe di base astratta per gli eventi di input.

Descrizione

Classe di base astratta per tutti i tipi di eventi di input. Vedi Node._input().

Tutorial

Proprietà

int

device

0

Metodi

bool

accumulate(with_event: InputEvent)

String

as_text() const

float

get_action_strength(action: StringName, exact_match: bool = false) const

bool

is_action(action: StringName, exact_match: bool = false) const

bool

is_action_pressed(action: StringName, allow_echo: bool = false, exact_match: bool = false) const

bool

is_action_released(action: StringName, exact_match: bool = false) const

bool

is_action_type() const

bool

is_canceled() const

bool

is_echo() const

bool

is_match(event: InputEvent, exact_match: bool = true) const

bool

is_pressed() const

bool

is_released() const

InputEvent

xformed_by(xform: Transform2D, local_ofs: Vector2 = Vector2(0, 0)) const


Costanti

DEVICE_ID_EMULATION = -1 🔗

ID dispositivo utilizzato per l'input del mouse emulato da un touchscreen o per l'input touch emulato da un mouse. Può essere utilizzato per distinguere l'input del mouse emulato dall'input del mouse fisico o l'input touch emulato dall'input touch fisico.

DEVICE_ID_KEYBOARD = 16 🔗

Device ID used for input from a keyboard. This can be used to distinguish keyboard input events from joypad input events.

DEVICE_ID_MOUSE = 32 🔗

Device ID used for input from a mouse. This can be used to distinguish mouse input events from joypad input events.


Descrizioni delle proprietà

int device = 0 🔗

  • void set_device(value: int)

  • int get_device()

ID dispositivo dell'evento.

Nota: device può essere negativo per casi d'uso speciali che non fanno riferimento a dispositivi fisicamente presenti sul sistema. Vedi DEVICE_ID_EMULATION.


Descrizioni dei metodi

bool accumulate(with_event: InputEvent) 🔗

Restituisce true se l'evento di input specificato e questo evento di input possono essere sommati (solo per gli eventi di tipo InputEventMouseMotion).

La posizione, la posizione globale e la velocità dell'evento di input specificato verranno copiate. Il relative risultante è una somma di entrambi gli eventi. I modificatori di entrambi gli eventi devono essere identici.


String as_text() const 🔗

Restituisce una rappresentazione String dell'evento.


float get_action_strength(action: StringName, exact_match: bool = false) const 🔗

Restituisce un valore compreso tra 0,0 e 1,0 a seconda dello stato delle azioni specificate. Utile per ottenere il valore degli eventi di tipo InputEventJoypadMotion.

Se exact_match è false, ignora i modificatori di input aggiuntivi per gli eventi InputEventKey e InputEventMouseButton e la direzione per gli eventi InputEventJoypadMotion.


bool is_action(action: StringName, exact_match: bool = false) const 🔗

Restituisce true se questo evento di input corrisponde a un'azione predefinita di qualsiasi tipo.

Se exact_match è false, ignora ulteriori modificatori di input per gli eventi InputEventKey e InputEventMouseButton e la direzione per gli eventi InputEventJoypadMotion.


bool is_action_pressed(action: StringName, allow_echo: bool = false, exact_match: bool = false) const 🔗

Returns true if the given action matches this event and is being pressed (and is not an echo event for InputEventKey events, unless allow_echo is true). Not relevant for events of type InputEventMouseMotion or InputEventScreenDrag.

If exact_match is false, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.

Note: Due to keyboard ghosting, is_action_pressed() may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.


bool is_action_released(action: StringName, exact_match: bool = false) const 🔗

Returns true if the given action matches this event and is released (i.e. not pressed). Not relevant for events of type InputEventMouseMotion or InputEventScreenDrag.

If exact_match is false, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.


bool is_action_type() const 🔗

Restituisce true se il tipo di questo evento di input è uno che si può assegnare a un'azione di input: InputEventKey, InputEventMouseButton, InputEventJoypadButton, InputEventJoypadMotion, InputEventAction. Restituisce false per tutti gli altri tipi di evento di input.


bool is_canceled() const 🔗

Restituisce true se questo evento di input è stato cancellato.


bool is_echo() const 🔗

Restituisce true se questo evento di input è un evento eco (solo per eventi di tipo InputEventKey). Un evento eco è un evento da un tasto ripetuto inviato quando l'utente tiene premuto il tasto. Qualsiasi altro tipo di evento restituisce false.

Nota: La frequenza con cui sono inviati gli eventi eco è in genere di circa 20 eventi al secondo (dopo aver tenuto premuto il tasto per circa mezzo secondo). Tuttavia, il ritardo/velocità di ripetizione del tasto può essere modificato dall'utente o disabilitato completamente nelle impostazioni del sistema operativo. Per garantire che il progetto funzioni correttamente su tutte le configurazioni, non dare per scontato che l'utente abbia una configurazione di ripetizione del tasto specifica nel comportamento del progetto.


bool is_match(event: InputEvent, exact_match: bool = true) const 🔗

Returns true if the specified event matches this event. Only valid for action events, which include key (InputEventKey), button (InputEventMouseButton or InputEventJoypadButton), axis InputEventJoypadMotion, and action (InputEventAction) events.

If exact_match is false, the check ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.

Note: This method only considers the event configuration (such as the keyboard key or the joypad axis), not state information like is_pressed(), is_released(), is_echo(), or is_canceled().


bool is_pressed() const 🔗

Restituisce true se questo evento di input è premuto. Non rilevante per eventi di tipo InputEventMouseMotion o InputEventScreenDrag.

Nota: A causa del ghosting della tastiera, is_pressed() potrebbe restituire false anche se è premuto uno dei tasti dell'azione. Per maggiori informazioni, vedi Esempi di input nella documentazione.


bool is_released() const 🔗

Restituisce true se questo evento di input è rilasciato. Non applicabile per gli eventi di tipo InputEventMouseMotion o InputEventScreenDrag.


InputEvent xformed_by(xform: Transform2D, local_ofs: Vector2 = Vector2(0, 0)) const 🔗

Restituisce una copia dell'evento di input specificato che è stato compensato da local_ofs e trasformato da xform. Applicabile per eventi di tipo InputEventMouseButton, InputEventMouseMotion, InputEventScreenTouch, InputEventScreenDrag, InputEventMagnifyGesture e InputEventPanGesture.