From e90ce866fa61ece9eca3b8e0846d46bb73752824 Mon Sep 17 00:00:00 2001 From: Cyril Oblikov Date: Mon, 25 Mar 2013 12:03:51 +0300 Subject: Fixed shortcuts for some (e.g. Russian) layouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If CMD modificator is active [nsevent characters] is used now to get keyCode. In this case for example English "X" is returned instead of Russian "Ч" even if Russian input source is selected. Task-number: QTBUG-30306 Change-Id: I93cd292633e68327df0c580ed74fe8ad1c9ed27d Reviewed-by: Friedemann Kleint Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qnsview.mm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 4ff44ca7f5..12a6bb9e69 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -837,6 +837,7 @@ static QTouchDevice *touchDevice = 0; ulong nativeModifiers = [nsevent modifierFlags]; Qt::KeyboardModifiers modifiers = [self 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 // use the value 0, since it indicates that the event originates from somewhere @@ -849,9 +850,12 @@ static QTouchDevice *touchDevice = 0; QChar ch; int keyCode; - if ([charactersIgnoringModifiers length] > 0) { - // convert the first character into a key code - ch = QChar([charactersIgnoringModifiers characterAtIndex:0]); + if ([charactersIgnoringModifiers length] > 0) { // convert the first character into a key code + if ((modifiers & Qt::ControlModifier) && ([characters length] != 0)) { + ch = QChar([characters characterAtIndex:0]); + } else { + ch = QChar([charactersIgnoringModifiers characterAtIndex:0]); + } keyCode = [self convertKeyCode:ch]; } else { // might be a dead key @@ -867,7 +871,7 @@ static QTouchDevice *touchDevice = 0; // ignore text for the U+F700-U+F8FF range. This is used by Cocoa when // delivering function keys (e.g. arrow keys, backspace, F1-F35, etc.) if ([charactersIgnoringModifiers length] == 1 && (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff)) - text = QCFString::toQString([nsevent characters]); + text = QCFString::toQString(characters); if (m_composingText.isEmpty()) m_sendKeyEvent = !QWindowSystemInterface::tryHandleShortcutEvent(m_window, timestamp, keyCode, modifiers, text); -- cgit v1.2.3