diff options
author | Michael Alexsander <michaelalexsander@protonmail.com> | 2022-08-30 20:18:06 -0300 |
---|---|---|
committer | Michael Alexsander <michaelalexsander@protonmail.com> | 2022-08-30 20:18:35 -0300 |
commit | 9e0de4e2cb1347279f2c09f92cc6be3edfe8a772 (patch) | |
tree | 493efc9f62c55388bc2fe3bb14879cbd90d9431a /scene | |
parent | 8fa9d1ae467632daa5f12b278eb616fd580a94ec (diff) |
Fix switching `MenuBar`'s menus with the keys while mouse hovering
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/menu_bar.cpp | 5 | ||||
-rw-r--r-- | scene/gui/menu_bar.h | 1 |
2 files changed, 6 insertions, 0 deletions
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; |