Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix MenuBar regression affecting touch input

Anish Kumar09cffcd87b16
diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp
index c1e71e47682..a9d4ef8f2a2 100644
--- a/scene/gui/menu_bar.cpp
+++ b/scene/gui/menu_bar.cpp
@@ -111,8 +111,9 @@ void MenuBar::gui_input(const Ref<InputEvent> &p_event) {
}
}
+ int event_device_id = p_event->get_device();
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid()) {
+ if (mb.is_valid() && event_device_id != InputEvent::DEVICE_ID_EMULATION) {
if (mb->is_pressed() && (mb->get_button_index() == MouseButton::LEFT || mb->get_button_index() == MouseButton::RIGHT)) {
int index = _get_index_at_point(mb->get_position());
if (index >= 0) {
@@ -120,6 +121,16 @@ void MenuBar::gui_input(const Ref<InputEvent> &p_event) {
}
}
}
+
+ Ref<InputEventScreenTouch> touch = p_event;
+ if (touch.is_valid() && event_device_id != InputEvent::DEVICE_ID_EMULATION) {
+ if (touch->is_released()) {
+ int index = _get_index_at_point(touch->get_position());
+ if (index >= 0) {
+ _open_popup(index);
+ }
+ }
+ }
}
void MenuBar::_open_popup(int p_index, bool p_focus_item) {