From 9e0de4e2cb1347279f2c09f92cc6be3edfe8a772 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Tue, 30 Aug 2022 20:18:06 -0300 Subject: Fix switching `MenuBar`'s menus with the keys while mouse hovering --- scene/gui/menu_bar.cpp | 5 +++++ scene/gui/menu_bar.h | 1 + 2 files changed, 6 insertions(+) (limited to 'scene/gui') diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp index 8aad14e1ec..db06fca587 100644 --- a/scene/gui/menu_bar.cpp +++ b/scene/gui/menu_bar.cpp @@ -377,6 +377,11 @@ void MenuBar::_notification(int p_what) { MutexLock lock(mutex); Vector2 pos = DisplayServer::get_singleton()->mouse_get_position() - mouse_pos_adjusted - get_global_position(); + if (pos == old_mouse_pos) { + return; + } + old_mouse_pos = pos; + int index = _get_index_at_point(pos); if (index >= 0 && index != active_menu) { selected_menu = index; diff --git a/scene/gui/menu_bar.h b/scene/gui/menu_bar.h index b7d9933ab2..5aa8ac7324 100644 --- a/scene/gui/menu_bar.h +++ b/scene/gui/menu_bar.h @@ -73,6 +73,7 @@ class MenuBar : public Control { int active_menu = -1; Vector2i mouse_pos_adjusted; + Vector2i old_mouse_pos; ObjectID shortcut_context; int _get_index_at_point(const Point2 &p_point) const; -- cgit v1.2.3