diff options
author | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-11-11 11:29:44 (GMT) |
---|---|---|
committer | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-11-11 15:09:52 (GMT) |
commit | 4b618e48c909fcc5665e9d60645023c48b2ffb43 (patch) | |
tree | 9a6ced55ae1f354f2632b6dfc97e452e3c5a7c4d /src/gui/kernel/qt_cocoa_helpers_mac.mm | |
parent | 54865d47cfd859a0e84ba8e1bbff3b56c93d4e0d (diff) | |
download | Qt-4b618e48c909fcc5665e9d60645023c48b2ffb43.zip Qt-4b618e48c909fcc5665e9d60645023c48b2ffb43.tar.gz Qt-4b618e48c909fcc5665e9d60645023c48b2ffb43.tar.bz2 |
ShortcutOverride has no effect on some shortcuts on Mac OS X (Cocoa).
When generating the native key sequences for menu items, Qt prefers the
non private unicode characters. But the characters in the NSEvent for
keyboard events can contain characters form the unicode range reserved
for Apple.
For e.g. when user presses the "delete" key, the event contains
NSDeleteFunctionKey, where in Qt is expecting NSDeleteCharacter. For now
this is the only key identified for translation. If we find similar
translations, those can be added to qt_mac_removePrivateUnicode().
Task-number: QTBUG-12495
Reviewed-by: Denis
Diffstat (limited to 'src/gui/kernel/qt_cocoa_helpers_mac.mm')
-rw-r--r-- | src/gui/kernel/qt_cocoa_helpers_mac.mm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 5a522f9..48d21e9 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -79,6 +79,7 @@ #include <qdesktopwidget.h> #include <qevent.h> #include <qpixmapcache.h> +#include <qvarlengtharray.h> #include <private/qevent_p.h> #include <private/qt_cocoa_helpers_mac_p.h> #include <private/qt_mac_p.h> @@ -616,6 +617,27 @@ Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags) return qtMods; } +NSString *qt_mac_removePrivateUnicode(NSString* string) +{ + int len = [string length]; + if (len) { + QVarLengthArray <unichar, 10> characters(len); + bool changed = false; + for (int i = 0; i<len; i++) { + characters[i] = [string characterAtIndex:i]; + // check if they belong to key codes in private unicode range + // currently we need to handle only the NSDeleteFunctionKey + if (characters[i] == NSDeleteFunctionKey) { + characters[i] = NSDeleteCharacter; + changed = true; + } + } + if (changed) + return [NSString stringWithCharacters:characters.data() length:len]; + } + return string; +} + Qt::KeyboardModifiers qt_cocoaDragOperation2QtModifiers(uint dragOperations) { Qt::KeyboardModifiers qtMods =Qt::NoModifier; |