Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-51643

QShortcut isn't working on OS X with non-English Input Source

    XMLWordPrintable

Details

    Description

      If QShortcut's QKeySequence (at least with modifiers) is first (in the current app launch) pressed on the keyboard when non-English input source is active, it won't work till restart of the app. If it was first pressed when English input source is active it will work after that with any input source.

      QLabel *label = new QLabel(0);
      label->show();
      label->setGeometry(100, 100, 640, 480);
      new QShortcut(QKeySequence("Ctrl+D"), label, SLOT(close()), 0, Qt::ApplicationShortcut);
      

      This can be reproduced if you have two input sources (I've tested with 1. "U.S." 2. "Russian - PC"), if you launch the app and press "Cmd+D" when U.S. input source is chosen, the label is closed. If the other input source is chosen, it won't work.

      As I've found out, difference happens on QCocoaKeyMapper::possibleKeys call, it produces different results depending on current input source, one of them works (with U.S.), other does not (with Russian - PC).

      It uses the result of QCocoaKeyMapper::updateKeyMap method, which caches it's result in keyLayout variable - that explains why the first press of the key sequence defines will it work the entire app launch or will it not.

      If I change in QCocoaKeyMapper::updateKeyboard method the line:

      QCFType<TISInputSourceRef> source = TISCopyCurrentKeyboardInputSource();
      

      to a line:

      QCFType<TISInputSourceRef> source = TISCopyCurrentASCIICapableKeyboardInputSource();
      

      it starts working correctly at least for my case. But I don't quite understand what of the code has which dependencies and does it break/ruin anything else and is it the right way to fix this problem.

      Test application is attached.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              tpochep Timur Pocheptsov
              johnpreston John Preston
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes