summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrasanth Ullattil <prasanth.ullattil@nokia.com>2009-04-17 09:13:34 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2009-04-17 13:26:48 (GMT)
commit9de17b04a82127f0a0ae941d490d5183fcac13b2 (patch)
tree83f17b3c15cca9ae7067166f3f0ede77cdb5e861
parent891cff5a6971a54fee32ca5b22d2eddf76667886 (diff)
downloadQt-9de17b04a82127f0a0ae941d490d5183fcac13b2.zip
Qt-9de17b04a82127f0a0ae941d490d5183fcac13b2.tar.gz
Qt-9de17b04a82127f0a0ae941d490d5183fcac13b2.tar.bz2
Line edit displays garbage when pressing up or down arrow keys (Cocoa).
The unicode characters between 0xF700 & 0xF8FF are special function-key code characters used by the NSEvent. These characters have to be ignored when converting to a QString. Task-number:244486 Reviewed-by:nrc (cherry picked from commit 5d39d424a92d89243207d8370d0fa1c6c8061668)
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 423898d..c874cf1 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -555,12 +555,15 @@ bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widge
int keyLength = [keyChars length];
if (keyLength == 0)
return false; // Dead Key, nothing to do!
+ bool ignoreText = false;
Qt::Key qtKey = Qt::Key_unknown;
if (keyLength == 1) {
QChar ch([keyChars characterAtIndex:0]);
if (ch.isLower())
ch = ch.toUpper();
qtKey = cocoaKey2QtKey(ch);
+ // Do not set the text for Function-Key Unicodes characters (0xF700–0xF8FF).
+ ignoreText = (ch.unicode() >= 0xF700 && ch.unicode() <= 0xF8FF);
}
Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([event modifierFlags]);
QString text;
@@ -568,7 +571,7 @@ bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widge
// To quote from the Carbon port: This is actually wrong--but it is the best that
// can be done for now because of the Control/Meta mapping issues
// (we always get text on the Mac)
- if (!(keyMods & (Qt::ControlModifier | Qt::MetaModifier)))
+ if (!ignoreText && !(keyMods & (Qt::ControlModifier | Qt::MetaModifier)))
text = QCFString::toQString(reinterpret_cast<CFStringRef>(keyChars));
UInt32 macScanCode = 1;