summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@digia.com>2013-05-06 14:07:10 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-30 17:01:19 +0200
commit9e36747786b31c9494f99af5e1f7c977b51b7ce7 (patch)
tree21577ee01a945c68ae6f9c3e0ba52dc7237795de /src/plugins/platforms/cocoa
parent12ae86119cf389dab368bbc8a9d49b29b0b155cd (diff)
Use [NSEvent characters] to retrieve the input character.
This is how it was done in Qt 4. An issue with the current approach was that it did not consider modifiers when setting a Qt::Key_* value, which would assign the same Qt keycode for: a = a(65) Alt + a = ā(65) [here it should return a unicode value for 'ā'] This is inconsistent with the other platform plugins. Also in the combination with a dead keys it was returning nothing in the output. Task-number: QTBUG-29005 (cherry picked from commit 6730413fcac1d7eb39af3683b87f965c5823cb6c) Change-Id: Ic28eb55b3a9798ecb6012cc2e3fb18589b8b0392 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index ee6a9616a6..5c5da830ac 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -897,7 +897,6 @@ 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
@@ -909,19 +908,11 @@ static QTouchDevice *touchDevice = 0;
EventRef eventRef = EventRef([nsevent eventRef]);
GetEventParameter(eventRef, kEventParamKeyCode, typeUInt32, 0, sizeof(nativeVirtualKey), 0, &nativeVirtualKey);
- QChar ch;
- int keyCode;
- 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]);
- }
+ QChar ch = QChar::ReplacementCharacter;
+ int keyCode = Qt::Key_unknown;
+ if ([characters length] != 0) {
+ ch = QChar([characters 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
@@ -931,7 +922,7 @@ static QTouchDevice *touchDevice = 0;
if (eventType == QEvent::KeyPress) {
// 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))
+ if (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff)
text = QCFString::toQString(characters);
if (m_composingText.isEmpty())