diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-08-19 10:40:10 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-08-22 20:10:11 +0200 |
commit | 03144190dfa329444d8941781d20265dfe7ce59c (patch) | |
tree | ac480d2be9a530647e4caa2208a59fe924612ce2 /src/plugins/platforms/cocoa | |
parent | cf6ab64f03723e254af9a28f431f076cffc7d54a (diff) |
Mac: close popups when the user clicks into the menubar
Otherwise it is possible to have a context menu and a menu from the
menu bar open at the same time. Native applications close the context
menu, but also block the click into the title bar. This change only
closes popups, the click goes through to the menubar.
Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-105474
Change-Id: I664c00eea83ba8fb43cc8a630d787f2d2b5b96ff
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenubar.mm | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 23aae466df..341ffb6ffc 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -13,6 +13,8 @@ #include <QtGui/QGuiApplication> #include <QtCore/QDebug> +#include <QtGui/private/qguiapplication_p.h> + QT_BEGIN_NAMESPACE static QList<QCocoaMenuBar*> static_menubars; @@ -21,6 +23,11 @@ QCocoaMenuBar::QCocoaMenuBar() { static_menubars.append(this); + // clicks into the menu bar should close all popup windows + static QMacNotificationObserver menuBarClickObserver(nil, NSMenuDidBeginTrackingNotification, ^{ + QGuiApplicationPrivate::instance()->closeAllPopups(); + }); + m_nativeMenu = [[NSMenu alloc] init]; #ifdef QT_COCOA_ENABLE_MENU_DEBUG qDebug() << "Construct QCocoaMenuBar" << this << m_nativeMenu; |