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>bb10
parent
321a549510
commit
19a6c50061
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue