summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2016-06-24 14:25:04 +0200
committerTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2016-07-29 12:28:35 +0000
commit2ff1557937c398a7fb5cc7ba120e7ca3b5eacd36 (patch)
tree9134edce646f5e8fda98be3ae2f5ba853ff61079 /src/plugins/platforms
parentc9354429dd90aff3f1174d0b56515cb4a8aef9c2 (diff)
Cocoa: Don’t beep on return keypress
Limit event propagation to AA_PluginApplication Applications. Change-Id: Id56ceea8d2aacae3f2be17f5894791de4eca528e Task-number: QTBUG-54211 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms')
-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 d4f2cf32fc..e88ae76c75 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -1662,12 +1662,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];
}