From bdebec4e2ef79f1771d2dcc22f9a919eb4487567 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 3 May 2013 13:30:01 +0200 Subject: [PATCH] Menu item shortcuts reaching Qt's event loop are disabled See comment in code and Cocoa event dispatching overview at https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html Task-number: QTBUG-30657 Change-Id: I88907aeeefa4962e1121495cd51af17a8e71b7de Reviewed-by: Frederik Gladhorn --- src/widgets/kernel/qshortcut.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index f323c682d1..c5cdce3d60 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -246,9 +246,19 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge QWidget *w = widgets.at(i); #ifndef QT_NO_MENU if (QMenu *menu = qobject_cast(w)) { +#ifdef Q_OS_MAC + // On Mac, menu item shortcuts are processed before reaching any window. + // That means that if a menu action shortcut has not been already processed + // (and reaches this point), then the menu item itself has been disabled. + // This occurs at the QPA level on Mac, were we disable all the Cocoa menus + // when showing a modal window. + Q_UNUSED(menu); + continue; +#else QAction *a = menu->menuAction(); if (correctActionContext(context, a, active_window)) return true; +#endif } else #endif if (correctWidgetContext(context, w, active_window))