From 9377881d6d6f5c07aa134c8f1708d0afd0d06e86 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 22 Jul 2009 16:53:49 +0200 Subject: "Emacs" style keyboard shortcuts don't work on Cocoa. Mac supports only single key shortcuts as key equivalent for menu items. So if a multiple key QKeySequence is set, use Qt's shortcut mechanism instead of the native menu shortcut mechanism. Task-number: 258438 Reviewed-by: Norwegian Rock Cat --- src/gui/kernel/qcocoaview_mac.mm | 9 ++++++++- src/gui/widgets/qmenu_mac.mm | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 3e5bfb6..3bc348c 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -1039,7 +1039,7 @@ extern "C" { - (void) insertText:(id)aString { - if ([aString length]) { + if ([aString length] && composing) { // Send the commit string to the widget. QString commitText; if ([aString isKindOfClass:[NSAttributedString class]]) { @@ -1052,7 +1052,14 @@ extern "C" { QInputMethodEvent e; e.setCommitString(commitText); qt_sendSpontaneousEvent(qwidget, &e); + } else { + // The key sequence "`q" on a French Keyboard will generate two calls to insertText before + // it returns from interpretKeyEvents. The first call will turn off 'composing' and accept + // the "`" key. The last keyDown event needs to be processed by the widget to get the + // character "q". The string parameter is ignored for the second call. + sendKeyEvents = true; } + composingText->clear(); } diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 77e98c4..a562076 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1376,8 +1376,9 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action) accel = qt_mac_menu_merge_accel(action); } } + // Show multiple key sequences as part of the menu text. if (accel.count() > 1) - text += QLatin1String(" (****)"); //just to denote a multi stroke shortcut + text += QLatin1String(" (") + accel.toString(QKeySequence::NativeText) + QLatin1String(")"); QString finalString = qt_mac_removeMnemonics(text); @@ -1466,7 +1467,8 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action) } #else [item setSubmenu:0]; - if (!accel.isEmpty()) { + // No key equivalent set for multiple key QKeySequence. + if (!accel.isEmpty() && accel.count() == 1) { [item setKeyEquivalent:keySequenceToKeyEqivalent(accel)]; [item setKeyEquivalentModifierMask:keySequenceModifierMask(accel)]; } else { -- cgit v0.12