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

Cocoa UCKeyTranslate replacement API (rdar://problem/33246214)

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • QPA
    • None
    • macOS

    Description

      The Unicode utilities APIs of Core Services. As such, it's not documented as deprecated. However, as of Xcode 8.3.1 and Xcode 9 beta 3 SDKs, it's part of the Carbon Core framework whose fate may be bound to the rest of the Carbon frameworks. Moreover, some of the APIs needed to use this function are part of HIToolbox. For example, the keyboardType parameter should be the value returned by LMGetKbdType, itself declared in HIToolbox/Events.h. Another example involves using API from HIToolbox/TextInputSource.h to get the 'uchr' data from the current input method for keyLayoutPtr. One more example, the modifierKeyState flags need symbols defined in HIToolbox/Events.h. Unfortunately, these modifier flags are not compatible with NSEventModifierFlags. (Notice also that, more generally, enum symbols representing keyCode values are only available in HIToolbox. See the documentation for CGEventCreateKeyboardEvent on why these are needed.)

      Within Qt, we use UCKeyTranslate as a way to accept a wide range of shortcuts in a platform independent way. Let's say we want a specific window of the application to accept the "Cmd+Shift+0" and "Shift+0" shortcuts. (While the latter shortcut would not make sense when there is text input involved, it may make sense in some types of applications, like games or media players.)

      What the application would receive from Cocoa for each shortcut are the following NSEvents:

      Shortcut: "Cmd+Shift+0"
      US layout NSEvent: type=KeyUp flags=0x12010a chars="0" unmodchars=")" keyCode=29
      Norwegian layout NSEvent: type=KeyUp flags=0x12010a chars="0" unmodchars="=" keyCode=29

      Shortcut: "Shift+0"
      US layout NSEvent: type=KeyUp flags=0x20102 chars=")" unmodchars=")" keyCode=29
      Norwegian layout NSEvent: type=KeyUp flags=0x20102 chars="=" unmodchars="=" keyCode=29

      Comparing the key events when using different keyboard layouts (US and Norwegian in this example), we can see that important information is missing for the "Shift+0" shortcut event. That information is available for "Cmd+Shift+0", which is arguably consistent with NSEvent.charactersIgnoringModifiers' documentation. So we keep the event keyCode which we run it through UCKeyTranslate with all combinations of key modifiers, and see if there's a possible match with any defined shortcut.

      To sum up, we'd like to know:

      1. Whether Unicode Utilities will go away with the rest of the Carbon frameworks. If yes, we'll need a replacement for UCKeyTranslate.

      2. UCKeyTranslate depends on functions and symbols found in HIToolbox, which we're expecting to disappear with the rest of the Carbon frameworks. If Unicode Utilities remains, we'll need a replacement for Text Input Source and related. See also  https://bugreport.apple.com/web/?problemID=33217689.

      Steps to Reproduce:
      Dig in the documentation and find something relevant to HIToolbox replacements.

      Expected Results:
      Replacement API in Cocoa.

      Observed Results:
      No replacement API in Cocoa.

      Version:
      macOS 10.12, macOS 10.13, and older versions all the way since Carbon was deprecated.

      Attachments

        Issue Links

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

          Activity

            People

              vestbo Tor Arne Vestbø
              sorvig Morten Sørvig
              Veli-Pekka Heinonen Veli-Pekka Heinonen
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes