From 1b76076c52d538174e42ca25005b538adc775a53 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 7 Jul 2022 16:07:22 -0300 Subject: [PATCH] Fix clicking a menuitem that is above another parent menubox/bar (fix #3386) --- src/ui/menu.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ui/menu.cpp b/src/ui/menu.cpp index 14412a199..55565c90d 100644 --- a/src/ui/menu.cpp +++ b/src/ui/menu.cpp @@ -461,12 +461,17 @@ bool MenuBox::onProcessMessage(Message* msg) gfx::Point mousePos = static_cast(msg)->position(); + // Get the widget below the mouse cursor + auto mgr = manager(); + if (!mgr) + break; + + Widget* picked = mgr->pick(mousePos); + // Here we catch the filtered messages (menu-bar or the // popuped menu-box) to detect if the user press outside of // the widget if (msg->type() == kMouseDownMessage && m_base != nullptr) { - Widget* picked = manager()->pick(mousePos); - // If one of these conditions are accomplished we have to // close all menus (back to menu-bar or close the popuped // menubox), this is the place where we control if... @@ -483,8 +488,6 @@ bool MenuBox::onProcessMessage(Message* msg) } } - // Get the widget below the mouse cursor - Widget* picked = menu->pick(mousePos); if (picked) { if ((picked->type() == kMenuItemWidget) && !(picked->hasFlags(DISABLED))) {