@@ -63,34 +63,32 @@ void BaseButton::gui_input(const Ref<InputEvent> &p_event) {
6363 return ;
6464 }
6565
66- if (p_event->get_device () == InputEvent::DEVICE_ID_EMULATION ) {
67- return ;
68- }
69-
70- Ref<InputEventScreenTouch> touch = p_event;
71- if (touch.is_valid ()) {
72- if (status.touch_index == -1 ) {
73- if (touch->is_pressed ()) {
74- status.touch_index = touch->get_index ();
75- status.press_attempt = true ;
76- status.pressing_inside = has_point (touch->get_position ());
77- on_action_event (p_event);
78- }
79- } else if (touch->get_index () == status.touch_index ) {
80- if (!touch->is_pressed ()) {
81- status.touch_index = -1 ;
82- on_action_event (p_event);
66+ if (p_event->get_device () != InputEvent::DEVICE_ID_EMULATION ) {
67+ Ref<InputEventScreenTouch> touch = p_event;
68+ if (touch.is_valid ()) {
69+ if (status.touch_index == -1 ) {
70+ if (touch->is_pressed ()) {
71+ status.touch_index = touch->get_index ();
72+ status.press_attempt = true ;
73+ status.pressing_inside = has_point (touch->get_position ());
74+ on_action_event (p_event);
75+ }
76+ } else if (touch->get_index () == status.touch_index ) {
77+ if (!touch->is_pressed ()) {
78+ status.touch_index = -1 ;
79+ on_action_event (p_event);
80+ }
8381 }
8482 }
85- }
8683
87- Ref<InputEventScreenDrag> drag = p_event;
88- if (drag.is_valid () && drag->get_index () == status.touch_index && status.press_attempt ) {
89- bool last_press_inside = status.pressing_inside ;
90- status.pressing_inside = has_point (drag->get_position ());
84+ Ref<InputEventScreenDrag> drag = p_event;
85+ if (drag.is_valid () && drag->get_index () == status.touch_index && status.press_attempt ) {
86+ bool last_press_inside = status.pressing_inside ;
87+ status.pressing_inside = has_point (drag->get_position ());
9188
92- if (last_press_inside != status.pressing_inside ) {
93- queue_redraw ();
89+ if (last_press_inside != status.pressing_inside ) {
90+ queue_redraw ();
91+ }
9492 }
9593 }
9694
@@ -102,17 +100,15 @@ void BaseButton::gui_input(const Ref<InputEvent> &p_event) {
102100 was_mouse_pressed = button_masked;
103101 on_action_event (p_event);
104102 was_mouse_pressed = false ;
105-
106- return ;
107- }
108-
109- Ref<InputEventMouseMotion> mouse_motion = p_event;
110- if (mouse_motion.is_valid ()) {
111- if (status.press_attempt ) {
112- bool last_press_inside = status.pressing_inside ;
113- status.pressing_inside = has_point (mouse_motion->get_position ());
114- if (last_press_inside != status.pressing_inside ) {
115- queue_redraw ();
103+ } else {
104+ Ref<InputEventMouseMotion> mouse_motion = p_event;
105+ if (mouse_motion.is_valid ()) {
106+ if (status.press_attempt ) {
107+ bool last_press_inside = status.pressing_inside ;
108+ status.pressing_inside = has_point (mouse_motion->get_position ());
109+ if (last_press_inside != status.pressing_inside ) {
110+ queue_redraw ();
111+ }
116112 }
117113 }
118114 }
0 commit comments