summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorPrasanth Ullattil <prasanth.ullattil@nokia.com>2010-06-24 08:34:56 (GMT)
committerPrasanth Ullattil <prasanth.ullattil@nokia.com>2010-06-24 08:42:57 (GMT)
commitd63e7d8ec0c9337999a3d90b594eb3e955145de9 (patch)
treea416366e409c275e0f53a95e39818e2dce551968 /src/gui/kernel
parent5b9173126253d6252eb09f8b34b707d28dbe1463 (diff)
downloadQt-d63e7d8ec0c9337999a3d90b594eb3e955145de9.zip
Qt-d63e7d8ec0c9337999a3d90b594eb3e955145de9.tar.gz
Qt-d63e7d8ec0c9337999a3d90b594eb3e955145de9.tar.bz2
QKeyEvent::text() inconsistency between Linux and Mac
For a key event triggered by the cursor keys, QKeyEvent::text() returns char with value 0x14 or similar. This patch (Cocoa only)will remove text from all key events for the unicode range 0xF700-0xF747. This is part of the corporate unicode range used by apple for keyboard function keys. [http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CORPCHAR.TXT] Task-number: QTBUG-11225 Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp15
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm7
2 files changed, 18 insertions, 4 deletions
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index 873b8f9..3dc6afc 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -866,14 +866,27 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
UInt32 macModifiers = 0;
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
sizeof(macModifiers), 0, &macModifiers);
+#ifdef QT_MAC_USE_COCOA
+ // The unicode characters in the range 0xF700-0xF747 are reserved
+ // by Mac OS X for transient use as keyboard function keys. We
+ // wont send 'text' for such key events. This is done to match
+ // behavior on other platforms.
+ unsigned int *unicodeKey = (unsigned int*)info;
+ if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747)
+ text = QString();
+ bool isAccepted;
+#endif
handled_event = QKeyMapper::sendKeyEvent(widget, grab,
(ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress,
qtKey, modifiers, text, ekind == kEventRawKeyRepeat, 0,
macScanCode, macVirtualKey, macModifiers
#ifdef QT_MAC_USE_COCOA
- ,static_cast<bool *>(info)
+ ,&isAccepted
#endif
);
+#ifdef QT_MAC_USE_COCOA
+ *unicodeKey = (unsigned int)isAccepted;
+#endif
}
return handled_event;
}
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 8cef03c..3fc27f4 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -682,10 +682,12 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve
NSEvent *event = static_cast<NSEvent *>(keyEvent);
EventRef key_event = static_cast<EventRef>(const_cast<void *>([event eventRef]));
Q_ASSERT(key_event);
+ unsigned int info = 0;
if ([event type] == NSKeyDown) {
NSString *characters = [event characters];
unichar value = [characters characterAtIndex:0];
qt_keymapper_private()->updateKeyMap(0, key_event, (void *)&value);
+ info = value;
}
// Redirect keys to alien widgets.
@@ -701,9 +703,8 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve
if (mustUseCocoaKeyEvent())
return qt_dispatchKeyEventWithCocoa(keyEvent, widgetToGetEvent);
- bool isAccepted;
- bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &isAccepted, true);
- return consumed && isAccepted;
+ bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &info, true);
+ return consumed && (info != 0);
#endif
}