diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-09-01 08:46:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-01 08:46:01 +0200 |
commit | 0a34994720b780ab612c0033c4f5335a862a5c72 (patch) | |
tree | 41dd0632031848252304512d62e415a8bd5d8612 | |
parent | e74809094fe40ae03ded178e2423c884e568c7cc (diff) | |
parent | 9e0de4e2cb1347279f2c09f92cc6be3edfe8a772 (diff) |
Merge pull request #65117 from YeldhamDev/menubar_key_fix
Fix switching `MenuBar`'s menus with the keys while mouse hovering
-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; |