Fix switching MenuBar
's menus with the keys while mouse hovering
This commit is contained in:
parent
8fa9d1ae46
commit
9e0de4e2cb
@ -377,6 +377,11 @@ void MenuBar::_notification(int p_what) {
|
|||||||
MutexLock lock(mutex);
|
MutexLock lock(mutex);
|
||||||
|
|
||||||
Vector2 pos = DisplayServer::get_singleton()->mouse_get_position() - mouse_pos_adjusted - get_global_position();
|
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);
|
int index = _get_index_at_point(pos);
|
||||||
if (index >= 0 && index != active_menu) {
|
if (index >= 0 && index != active_menu) {
|
||||||
selected_menu = index;
|
selected_menu = index;
|
||||||
|
@ -73,6 +73,7 @@ class MenuBar : public Control {
|
|||||||
int active_menu = -1;
|
int active_menu = -1;
|
||||||
|
|
||||||
Vector2i mouse_pos_adjusted;
|
Vector2i mouse_pos_adjusted;
|
||||||
|
Vector2i old_mouse_pos;
|
||||||
ObjectID shortcut_context;
|
ObjectID shortcut_context;
|
||||||
|
|
||||||
int _get_index_at_point(const Point2 &p_point) const;
|
int _get_index_at_point(const Point2 &p_point) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user