summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-01-12 13:53:53 +0100
committerAndy Shaw <andy.shaw@qt.io>2017-09-08 17:30:10 +0000
commit202d3ba3e6c9982608f41f5e7d836825c8664c93 (patch)
treea2c53b86e3d1b940f2b02fbbaff0a362943f8f31 /src
parent82ed3b8ca5ab5c47efde39083fe0ad12bdcafa7f (diff)
Cocoa: Check if charactersIgnoringModifiers is not empty too
If a dead key occurs as a result of pressing a key combination then characters will have 0 length, but charactersIgnoringModifiers will have a valid character in it. This enables key combinations such as ALT+E to be used as a shortcut with an English keyboard even though pressing ALT+E will give a dead key while doing normal text input. Task-number: QTBUG-57933 Change-Id: I52fe9edacefe7298a96af5430831f805626bacd2 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 04e02a274a..9207feb5fd 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -1523,10 +1523,16 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QChar ch = QChar::ReplacementCharacter;
int keyCode = Qt::Key_unknown;
- if ([characters length] != 0) {
+
+ // If a dead key occurs as a result of pressing a key combination then
+ // characters will have 0 length, but charactersIgnoringModifiers will
+ // have a valid character in it. This enables key combinations such as
+ // ALT+E to be used as a shortcut with an English keyboard even though
+ // pressing ALT+E will give a dead key while doing normal text input.
+ if ([characters length] != 0 || [charactersIgnoringModifiers length] != 0) {
if (((modifiers & Qt::MetaModifier) || (modifiers & Qt::AltModifier)) && ([charactersIgnoringModifiers length] != 0))
ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
- else
+ else if ([characters length] != 0)
ch = QChar([characters characterAtIndex:0]);
keyCode = [self convertKeyCode:ch];
}