summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2012-05-22 13:41:50 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-23 14:18:34 +0200
commit19a6c50061ec2feb86895c6ffee500bf58c14809 (patch)
tree57b14ed3c34f30f5c76419118794557457e9d043 /src/plugins/platforms
parent321a5495101b769feb6dae1dcb703effc9e3bd52 (diff)
Cocoa: Handle keyboard dead keys correctly
Some keyboard layouts have physical dead keys (like the ¨ key on a Norwegian keyboard). These do not send any text, so we should not use [NSString characterAtIndex:0] if the string is empty. When encountering an empty [NSEvent character] string, use Qt::Key_unknown and QChar::ReplacementCharacter. Change-Id: I7281aa9ea6005341c0dcfa5900bfe601e4eac6a9 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 09ba1c50ae..e0fc678656 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -612,8 +612,18 @@ static QTouchDevice *touchDevice = 0;
ulong timestamp = [nsevent timestamp] * 1000;
Qt::KeyboardModifiers modifiers = [self convertKeyModifiers:[nsevent modifierFlags]];
NSString *charactersIgnoringModifiers = [nsevent charactersIgnoringModifiers];
- QChar ch([charactersIgnoringModifiers characterAtIndex:0]);
- int keyCode = [self convertKeyCode:ch];
+
+ QChar ch;
+ int keyCode;
+ if ([charactersIgnoringModifiers length] > 0) {
+ // convert the first character into a key code
+ ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
+ keyCode = [self convertKeyCode:ch];
+ } else {
+ // might be a dead key
+ ch = QChar::ReplacementCharacter;
+ keyCode = Qt::Key_unknown;
+ }
// we will send a key event unless the input method sets m_sendKeyEvent to false
m_sendKeyEvent = true;