Skip to content

Commit

Permalink
Cocoa: Don’t beep on return keypress
Browse files Browse the repository at this point in the history
Limit event propagation to AA_PluginApplication
Applications.

Change-Id: Id56ceea8d2aacae3f2be17f5894791de4eca528e
Task-number: QTBUG-54211
Reviewed-by: Timur Pocheptsov <[email protected]>
  • Loading branch information
Morten Johan Sørvig authored and Timur Pocheptsov committed Jul 29, 2016
1 parent c935442 commit 2ff1557
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/plugins/platforms/cocoa/qnsview.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1662,12 +1662,18 @@ - (void)keyDown:(NSEvent *)nsevent

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];
}

Expand Down

0 comments on commit 2ff1557

Please sign in to comment.