summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qnsview.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview.mm')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index a72cbd010a..500049a504 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -1625,12 +1625,18 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const bool accepted = [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)];
- // Track keyDown acceptance state for later acceptance of the keyUp.
- if (accepted)
+ // When Qt is used to implement a plugin for a native application we
+ // want to propagate unhandled events to other native views. However,
+ // Qt does not always set the accepted state correctly (in particular
+ // for return key events), so do this for plugin applications only
+ // to prevent incorrect forwarding in the general case.
+ const bool shouldPropagate = QCoreApplication::testAttribute(Qt::AA_PluginApplication) && !accepted;
+
+ // Track keyDown acceptance/forward state for later acceptance of the keyUp.
+ if (!shouldPropagate)
m_acceptedKeyDowns.insert([nsevent keyCode]);
- // Propagate the keyDown to the next responder if Qt did not accept it.
- if (!accepted)
+ if (shouldPropagate)
[super keyDown:nsevent];
}