summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-09-22 08:18:16 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-09-22 08:29:04 (GMT)
commitc3ad479d449375ca4b600d62e4c72b34a36736d7 (patch)
treefdd87a3e530cad55ca25953f521c77ed9077a20c /src
parentdbe7af4ad982186d26f6e3dbf5dad8e97b318443 (diff)
downloadQt-c3ad479d449375ca4b600d62e4c72b34a36736d7.zip
Qt-c3ad479d449375ca4b600d62e4c72b34a36736d7.tar.gz
Qt-c3ad479d449375ca4b600d62e4c72b34a36736d7.tar.bz2
QTBUG-13301: The menubar does now work when no window is showing
The reason is that actions from the menu bar have no target, and is therefore sendt down the responder chain. This is sometimes neccessary to make it work with modal dialogs. But this also means that there will be no first responder window to catch the action if no window is showing on screen. Luckily, in 4.8, we added our own QNSApplication. And this will also be the last resort in the responder chaing. Hence, we add code to handle the menu bar action here. Rev-by: carlos
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qcocoaapplication_mac.mm11
-rw-r--r--src/gui/kernel/qcocoasharedwindowmethods_mac_p.h10
2 files changed, 11 insertions, 10 deletions
diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm
index 9270213..1b30efd 100644
--- a/src/gui/kernel/qcocoaapplication_mac.mm
+++ b/src/gui/kernel/qcocoaapplication_mac.mm
@@ -183,6 +183,17 @@ QT_USE_NAMESPACE
[super sendEvent:event];
}
+- (void)qtDispatcherToQAction:(id)sender
+{
+ // Forward actions sendt from the menu bar (e.g. quit) to the menu loader.
+ // Having this method here means that we are the last stop in the responder
+ // chain, and that we are able to handle menu actions even when no window is
+ // visible on screen. Note: If Qt is used as a plugin, Qt will not use a
+ // native menu bar. Hence, we will also not need to do any redirection etc. as
+ // we do with sendEvent.
+ [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
+}
+
@end
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
index 970bc0a..efe045c 100644
--- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
@@ -136,16 +136,6 @@ QT_END_NAMESPACE
qt_dispatchTabletProximityEvent(tabletEvent);
}
-- (void)qtDispatcherToQAction:(id)sender
-{
- // If this window is modal, the menu bar will be modally shaddowed.
- // In that case, since the window will be in the first responder chain,
- // we can still catch the trigger here and forward it to the menu bar.
- // This is needed as a single modal dialog on Qt should be able to access
- // the application menu (e.g. quit).
- [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
-}
-
- (void)terminate:(id)sender
{
// This function is called from the quit item in the menubar when this window