Fixed an another issue with touch gui input handling.

This commit is contained in:
Relintai 2022-12-12 18:30:35 +01:00
parent 94a9792d02
commit c7809991b2

View File

@ -2217,14 +2217,15 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (touch_event->is_pressed()) { if (touch_event->is_pressed()) {
Control *over = _gui_find_control(pos); Control *over = _gui_find_control(pos);
if (over) { if (over) {
gui.touch_focus[touch_index] = over->get_instance_id();
if (!gui.modal_stack.empty()) { if (!gui.modal_stack.empty()) {
Control *top = gui.modal_stack.back()->get(); Control *top = gui.modal_stack.back()->get();
if (over != top && !top->is_a_parent_of(over)) { if (over != top && !top->is_a_parent_of(over)) {
return; return;
} }
} }
if (over->can_process()) { if (over->can_process()) {
gui.touch_focus[touch_index] = over->get_instance_id();
touch_event = touch_event->xformed_by(Transform2D()); //make a copy touch_event = touch_event->xformed_by(Transform2D()); //make a copy
if (over == gui.mouse_focus) { if (over == gui.mouse_focus) {
pos = gui.focus_inv_xform.xform(pos); pos = gui.focus_inv_xform.xform(pos);
@ -2234,12 +2235,14 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
touch_event->set_position(pos); touch_event->set_position(pos);
_gui_call_input(over, touch_event); _gui_call_input(over, touch_event);
} }
set_input_as_handled(); set_input_as_handled();
return; return;
} }
} else { } else {
ObjectID control_id = gui.touch_focus[touch_index]; ObjectID control_id = gui.touch_focus[touch_index];
Control *over = Object::cast_to<Control>(ObjectDB::get_instance(control_id)); Control *over = Object::cast_to<Control>(ObjectDB::get_instance(control_id));
if (over && over->can_process()) { if (over && over->can_process()) {
touch_event = touch_event->xformed_by(Transform2D()); //make a copy touch_event = touch_event->xformed_by(Transform2D()); //make a copy
if (over == gui.last_mouse_focus) { if (over == gui.last_mouse_focus) {