Add methods to check which event first triggered "just pressed/released" state.
This commit is contained in:
@ -483,7 +483,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
if (p_event->is_action("ui_down", true) && p_event->is_pressed()) {
|
||||
if (is_joypad_event) {
|
||||
if (!input->is_action_just_pressed("ui_down", true)) {
|
||||
if (!input->is_action_just_pressed_by_event("ui_down", p_event, true)) {
|
||||
return;
|
||||
}
|
||||
joypad_event_process = true;
|
||||
@ -526,7 +526,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
} else if (p_event->is_action("ui_up", true) && p_event->is_pressed()) {
|
||||
if (is_joypad_event) {
|
||||
if (!input->is_action_just_pressed("ui_up", true)) {
|
||||
if (!input->is_action_just_pressed_by_event("ui_up", p_event, true)) {
|
||||
return;
|
||||
}
|
||||
joypad_event_process = true;
|
||||
|
||||
@ -136,7 +136,7 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
|
||||
return;
|
||||
}
|
||||
if (is_joypad_event) {
|
||||
if (!input->is_action_just_pressed("ui_left", true)) {
|
||||
if (!input->is_action_just_pressed_by_event("ui_left", p_event, true)) {
|
||||
return;
|
||||
}
|
||||
set_process_internal(true);
|
||||
@ -152,7 +152,7 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
|
||||
return;
|
||||
}
|
||||
if (is_joypad_event) {
|
||||
if (!input->is_action_just_pressed("ui_right", true)) {
|
||||
if (!input->is_action_just_pressed_by_event("ui_right", p_event, true)) {
|
||||
return;
|
||||
}
|
||||
set_process_internal(true);
|
||||
@ -168,7 +168,7 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
|
||||
return;
|
||||
}
|
||||
if (is_joypad_event) {
|
||||
if (!input->is_action_just_pressed("ui_up", true)) {
|
||||
if (!input->is_action_just_pressed_by_event("ui_up", p_event, true)) {
|
||||
return;
|
||||
}
|
||||
set_process_internal(true);
|
||||
@ -180,7 +180,7 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
|
||||
return;
|
||||
}
|
||||
if (is_joypad_event) {
|
||||
if (!input->is_action_just_pressed("ui_down", true)) {
|
||||
if (!input->is_action_just_pressed_by_event("ui_down", p_event, true)) {
|
||||
return;
|
||||
}
|
||||
set_process_internal(true);
|
||||
|
||||
@ -315,7 +315,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) {
|
||||
bool is_joypad_event = (joypadmotion_event.is_valid() || joypadbutton_event.is_valid());
|
||||
if (p_event->is_action("ui_right", true)) {
|
||||
if (is_joypad_event) {
|
||||
if (!input->is_action_just_pressed("ui_right", true)) {
|
||||
if (!input->is_action_just_pressed_by_event("ui_right", p_event, true)) {
|
||||
return;
|
||||
}
|
||||
set_process_internal(true);
|
||||
@ -325,7 +325,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
} else if (p_event->is_action("ui_left", true)) {
|
||||
if (is_joypad_event) {
|
||||
if (!input->is_action_just_pressed("ui_left", true)) {
|
||||
if (!input->is_action_just_pressed_by_event("ui_left", p_event, true)) {
|
||||
return;
|
||||
}
|
||||
set_process_internal(true);
|
||||
|
||||
@ -2301,15 +2301,15 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
||||
if (joypadmotion_event.is_valid()) {
|
||||
Input *input = Input::get_singleton();
|
||||
|
||||
if (p_event->is_action_pressed(SNAME("ui_focus_next")) && input->is_action_just_pressed(SNAME("ui_focus_next"))) {
|
||||
if (p_event->is_action_pressed(SNAME("ui_focus_next")) && input->is_action_just_pressed_by_event(SNAME("ui_focus_next"), p_event)) {
|
||||
next = from->find_next_valid_focus();
|
||||
}
|
||||
|
||||
if (p_event->is_action_pressed(SNAME("ui_focus_prev")) && input->is_action_just_pressed(SNAME("ui_focus_prev"))) {
|
||||
if (p_event->is_action_pressed(SNAME("ui_focus_prev")) && input->is_action_just_pressed_by_event(SNAME("ui_focus_prev"), p_event)) {
|
||||
next = from->find_prev_valid_focus();
|
||||
}
|
||||
|
||||
if (p_event->is_action_pressed(SNAME("ui_accessibility_drag_and_drop")) && input->is_action_just_pressed(SNAME("ui_accessibility_drag_and_drop"))) {
|
||||
if (p_event->is_action_pressed(SNAME("ui_accessibility_drag_and_drop")) && input->is_action_just_pressed_by_event(SNAME("ui_accessibility_drag_and_drop"), p_event)) {
|
||||
if (gui_is_dragging()) {
|
||||
from->accessibility_drop();
|
||||
} else {
|
||||
@ -2317,19 +2317,19 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
||||
}
|
||||
}
|
||||
|
||||
if (p_event->is_action_pressed(SNAME("ui_up")) && input->is_action_just_pressed(SNAME("ui_up"))) {
|
||||
if (p_event->is_action_pressed(SNAME("ui_up")) && input->is_action_just_pressed_by_event(SNAME("ui_up"), p_event)) {
|
||||
next = from->_get_focus_neighbor(SIDE_TOP);
|
||||
}
|
||||
|
||||
if (p_event->is_action_pressed(SNAME("ui_left")) && input->is_action_just_pressed(SNAME("ui_left"))) {
|
||||
if (p_event->is_action_pressed(SNAME("ui_left")) && input->is_action_just_pressed_by_event(SNAME("ui_left"), p_event)) {
|
||||
next = from->_get_focus_neighbor(SIDE_LEFT);
|
||||
}
|
||||
|
||||
if (p_event->is_action_pressed(SNAME("ui_right")) && input->is_action_just_pressed(SNAME("ui_right"))) {
|
||||
if (p_event->is_action_pressed(SNAME("ui_right")) && input->is_action_just_pressed_by_event(SNAME("ui_right"), p_event)) {
|
||||
next = from->_get_focus_neighbor(SIDE_RIGHT);
|
||||
}
|
||||
|
||||
if (p_event->is_action_pressed(SNAME("ui_down")) && input->is_action_just_pressed(SNAME("ui_down"))) {
|
||||
if (p_event->is_action_pressed(SNAME("ui_down")) && input->is_action_just_pressed_by_event(SNAME("ui_down"), p_event)) {
|
||||
next = from->_get_focus_neighbor(SIDE_BOTTOM);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user