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

Multi-modifier key events not correctly handled on macOS

    XMLWordPrintable

Details

    • macOS
    • 085d5db90 (dev), 79cb221f9 (6.7), 5c32d48a3 (tqtc/lts-6.5), 9e5e8ec25 (tqtc/lts-6.2)

    Description

      With Qt 6.2 the handling of key events has been overhauled with commit 9e1875483ceaf907226f84cd6a58ab59f7f16f80 to assume that the input method handles key events. This leads to numerous issues which result in no key input events being emitted via `keyPressEvent`. The main cause of this issue is `interpretKeyEvents` resulting in neither `insertText` nor `doCommandBySelector` being called (observed with events involving CMD key) or the check in Qt's implementation of `interpretKeyEvents` (`[text isEqualToString:eventText]`) failing and thus `m_sendKeyEvent` stays at `false`.

      Testing with a simple test application found via GitHub Gist (https://gist.github.com/MasonRemaley/af5e1d3c538aedbfd6c726762205b1fb) it seems that `interpetKeyEvents` drops all combinations of the CMD-key with either ALT or CTRL modifiers (SHIFT modifier is accepted):

      • CMD+A - `doCommandBySelector`
      • CMD+SHIFT+A - `doCommandBySelector`
      • CMD+ALT+A - Nothing
      • CMD+CTRL+A - Nothing
      • CMD+CTRL+ALT+A - Nothing

      The ALT key switches macOS inputs to special character mode, with SHIFT switching to a third input map - in these cases `insertText` is called with the appropriate character. Adding CTRL to the mix does not change the resulting text passed into the callback, but the `characters` property of the current event will be an empty string. Thus the check `[text isEqualToString:eventText]` evaluates to `false` and Qt drops the event. When the receiving Widget is a text input, this will result in the corresponding character being inserted into the input field however, without the app receiving a key event.

      In OBS we make use of the built-in key event handling to record keystrokes for hotkey handling - the issue described above leads to a regression of functionality on macOS:

      • When the CMD key is involved, only CMD+KEY or CMD+SHIFT+KEY inputs are received via key events
      • When the ALT key is involved, only ALT+KEY or ALT+SHIFT+KEY inputs are received via key events, combinations with CMD don't yield any events, combinations with CTRL are inserted into an input field but don't yield a key event
      • When The CTRL key is involved, only CTRL+KEY or CTRL+SHIFT+KEY inputs are received via key events, for combinations with CMD or ALT see above

      This limits the amount and combinations of key events users can bind as hotkeys in OBS.

      Attachments

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

        Activity

          People

            vestbo Tor Arne Vestbø
            gxalpha Sebastian Beckmann
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: