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

Ctrl+Alt+Key inputs capitalized letter into all edit fields

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.14.2
    • None
    • Windows

    Description

      Steps to reproduce: When any of the input fields is focused (QLineEdit, QComboBox, etc), press Ctrl+Alt+h (or any other letter).

      Expected result: no text should appear in the edit field, because the pressed combination doesn't produce any character.

      Actual result: an uppercase 'H' is added to the input field, as if Shift+h were pressed.

      Cause of this bug is in: src\qtbase\src\plugins\platforms\windows\qwindowskeymapper.cpp 
      QWindowsKeyMapper::translateKeyEventInternal() (line 1130 and below)

      Upon receiving WM_KEYDOWN event, it calls PeekMessage to get WM_CHAR events, from there it gets the inputted Unicode text, stores it in the 'uch' variable, and later puts into QKeyEvent::txt member.

      So far so good. However, when one presses Ctrl+Alt+h, there are no WM_CHAR events in the event queue because this combination does not result in any text. In this case Qt enters the "if (uch.isNull())" branch which has the following comment: "// If no ?_CHAR was found in the queue; deduct character from the ?_KEYDOWN parameters". From there it calls MapVirtualKey with the key code, which always returns the uppercase character even when no Shift key is pressed. It then puts this uppercase character into QKeyEvent::txt, which is wrong.

      Solution 1: Do not call MapVirtualKey when no WM_CHAR is in the event queue and leave QKeyEvent::txt empty, as it should be.

      Solution 2: Check for Ctrl/Alt modifiers and do not call MapVirtualKey at least when these modifiers are pressed, because Ctrl+Alt+letter should not produce any input. When Ctrl+Alt are not pressed, at least check the Shift status and convert the result of MapVirtualKey to lowercase when Shift is not pressed.

      The current code which always puts an the uppercase letter from MapVirtualKey to QKeyEvent::txt is wrong in any case.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            ttg ttg
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes