1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-13 13:31:48 +00:00

Augment the InputEvent class with a CANCELED state

The `InputEvent` class currently supports the `pressed` and `released` states, which given the binary nature, is represented by a `bool` field.
This commit introduced the `CANCELED` state, which signals that an ongoing input event has been canceled.
To represent all the states, the `InputEventState` enum is added and the `InputEvent` logic is refactored accordingly.
This commit is contained in:
Fredia Huya-Kouadio
2023-05-03 14:23:34 -07:00
parent 716fef79ef
commit 94d6c3dcc6
8 changed files with 74 additions and 65 deletions

View File

@@ -360,6 +360,7 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
Ref<InputEventScreenTouch> touch_event;
touch_event.instance();
touch_event->set_pressed(mb->is_pressed());
touch_event->set_canceled(mb->is_canceled());
touch_event->set_position(mb->get_position());
touch_event->set_double_tap(mb->is_doubleclick());
_THREAD_SAFE_UNLOCK_
@@ -426,6 +427,7 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
button_event->set_position(st->get_position());
button_event->set_global_position(st->get_position());
button_event->set_pressed(st->is_pressed());
button_event->set_canceled(st->is_canceled());
button_event->set_button_index(BUTTON_LEFT);
button_event->set_doubleclick(st->is_double_tap());
if (st->is_pressed()) {