Mac OSX: get the correct key code when the control key is pressed
The control key results in modifiers having Qt::MetaModifier, and then the correct character is found in charactersIgnoringModifiers. The rest of the time, [nsevent characters] seems to be correct. If we use charactersIgnoringModifiers too much of the time, then the keycode will be wrong in some cases even though typing is still possible. Task-number: QTBUG-29005 Task-number: QTBUG-31811 Task-number: QTBUG-31977 Change-Id: Ib23b89f03bc9a61fe6d177320fa603c05649e979 Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>bb10
parent
3ffc86e0e6
commit
e3cf87bb75
|
|
@ -914,6 +914,7 @@ static QTouchDevice *touchDevice = 0;
|
|||
ulong timestamp = [nsevent timestamp] * 1000;
|
||||
ulong nativeModifiers = [nsevent modifierFlags];
|
||||
Qt::KeyboardModifiers modifiers = [QNSView convertKeyModifiers: nativeModifiers];
|
||||
NSString *charactersIgnoringModifiers = [nsevent charactersIgnoringModifiers];
|
||||
NSString *characters = [nsevent characters];
|
||||
|
||||
// [from Qt 4 impl] There is no way to get the scan code from carbon. But we cannot
|
||||
|
|
@ -928,7 +929,10 @@ static QTouchDevice *touchDevice = 0;
|
|||
QChar ch = QChar::ReplacementCharacter;
|
||||
int keyCode = Qt::Key_unknown;
|
||||
if ([characters length] != 0) {
|
||||
ch = QChar([characters characterAtIndex:0]);
|
||||
if ((modifiers & Qt::MetaModifier) && ([charactersIgnoringModifiers length] != 0))
|
||||
ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
|
||||
else
|
||||
ch = QChar([characters characterAtIndex:0]);
|
||||
keyCode = [self convertKeyCode:ch];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue