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

macOS: First Hangul input ignored/separated after locale change or initial focus with default Korean IME

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.8.3, 6.9.0
    • None
    • macOS
    • macOS

    Description

      When using a QWidget-based application on macOS with the default Korean IME (2-Set or 3-Set), there is an issue where the IME fails to correctly handle the very first Hangul character input after certain events. This occurs in two main scenarios:

      1. After switching locale programmatically: When the input locale is changed from a non-Korean locale (e.g., English) to Korean while a widget (e.g., a custom text editor derived from QWidget) has focus.
      1. On initial focus: When the application starts and a widget gains focus for the first time while the system's active IME is already set to Korean.

      In both scenarios, the first Hangul character input attempt fails to initiate proper composition via the IME.

      Steps to Reproduce:

      Scenario 1: Locale Change

      1. Launch the attached minimal reproducible example (MRE) application (or a simple application with a focusable QWidget).
      1. Ensure the system input method is set to English.
      1. Give focus to the target widget.
      1. Programmatically switch the system input method to Korean (e.g., macOS default 2-Set Korean). The QInputMethod::localeChanged() signal is correctly emitted, and QGuiApplication::inputMethod()->locale().language() returns QLocale::Korean.
      1. Immediately try to type a Hangul character, for example, press the key corresponding to 'ㅎ' (e.g., the 'g' key on a QWERTY layout).

      Scenario 2: Initial Focus

      1. Set the macOS system input method to Korean (e.g., default 2-Set Korean) before launching the application.
      1. Launch the MRE application.
      1. The target widget gains focus automatically (or click to give it focus).
      1. Immediately try to type a Hangul character, for example, press the key corresponding to 'ㅎ'.

      Actual Results:

      • The keyPressEvent for the first Hangul key is received by the widget.
      • Calling the base QWidget::keyPressEvent does not result in the event being accepted (returns false), indicating the IME did not handle it to start composition.
      • No QInputMethodEvent with a preedit string is generated for this first key press.
      • Often, the corresponding base jamo (e.g., 'ㅎ') is inserted directly into the widget if the widget has fallback handling for unaccepted key events with text.
      • Subsequent Hangul key presses after the first one are correctly handled by the IME, starting composition (generating preedit strings and committing characters), but the first character remains incorrectly inserted or separated.
      • Note: The behavior with the 3-Set IME can sometimes be slightly different (e.g., sometimes committing an unexpected character like 'ㅡ' immediately upon receiving the key event), but the core issue of failing to start composition correctly on the first input remains.

      Expected Results:

      • The first Hangul key press after the locale change or on initial focus should be correctly intercepted and handled by the macOS default Korean IME.
      • An inputMethodEvent should be generated with a preedit string (e.g., "ㅎ"), initiating the Hangul composition process.
      • The base QWidget::keyPressEvent should ideally indicate that the event was accepted by the input method system.
      • No incorrect characters (like separated jamo) should be inserted directly.

      Additional Information:

      • This issue occurs specifically with the default macOS Korean IMEs. Third-party IMEs like Gureum function correctly under the same conditions.
      • The problem seems related to the IME not being properly activated or ready to compose immediately after a locale change detected by Qt or upon receiving initial focus when the Korean IME is pre-selected.
      • The custom widget in the MRE handles keyPressEvent and inputMethodEvent in a standard way. QGuiApplication::inputMethod()->update() is called when necessary.

      Attachments

        1. CMakeLists.txt
          0.4 kB
          Taesup Jang
        2. debug-log.txt
          5 kB
          Taesup Jang
        3. Korean IME MRE (QLineEdit).png
          46 kB
          Taesup Jang
        4. main.cpp
          5 kB
          Taesup Jang
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            taesup_jang Taesup Jang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes