Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
6.2.4, 6.3
-
-
6767ac20c9 (qt/qtbase/dev) 6767ac20c9 (qt/tqtc-qtbase/dev) d7c33f16d9 (qt/tqtc-qtbase/6.2) 1311870125 (qt/qtbase/6.4) 1311870125 (qt/tqtc-qtbase/6.4) ab6721947c (qt/qtbase/6.3) ab6721947c (qt/tqtc-qtbase/6.3)
Description
Code
import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 ApplicationWindow { id: root width: 200 height: 150 visible: true Column { anchors.fill: parent Frame { focus: true Keys.onPressed: (event) => { console.log( "[Frame.Keys.onPressed]", "Key: 0x"+event.key.toString(16), "Modifiers: 0x"+event.modifiers.toString(16) ) event.accepted = true; } } TextField { placeholderText: "Click here to focus" Keys.onPressed: (event) => { console.log( "[TextField.Keys.onPressed]", "Key: 0x"+event.key.toString(16), "Modifiers: 0x"+event.modifiers.toString(16) ) } } } Component.onCompleted: { console.log( "The value of Qt.Key_Return is 0x" + Number(Qt.Key_Return).toString(16) ); console.log( "The value of Qt.Key_Enter is 0x" + Number(Qt.Key_Enter).toString(16) ); console.log( "The value of Qt.KeypadModifier is 0x" + Number(Qt.KeypadModifier).toString(16) ); } }
Steps to reproduce
- Run the code above. It will automatically force active focus on the Frame.
- Press [Return] (on the main keyboard)
- Press [Enter] (on the keypad)
- Press [Fn]+[Return]
- Click on the TextField to move active focus to the TextField.
- Repeat steps #2-#4 while the TextField has active focus.
Note: For Step #4, [Fn]+[Return] is supposed to produce [Enter], according to https://apple.stackexchange.com/questions/47565/return-vs-enter
Clarification
qml: The value of Qt.Key_Return is 0x1000004 qml: The value of Qt.Key_Enter is 0x1000005 qml: The value of Qt.KeypadModifier is 0x20000000
Results
The value of event.key matches the pressed key when the Frame had active focus. However, when the TextField had active focus, event.key has the wrong value on macOS:
QML output on Windows (all correct) | QML output on macOS (TextField wrong) | |
---|---|---|
Step #2 on Frame | [Frame.Keys.onPressed] Key: 0x1000004 Modifiers: 0x0 | [Frame.Keys.onPressed] Key: 0x1000004 Modifiers: 0x0 |
Step #3 on Frame | [Frame.Keys.onPressed] Key: 0x1000005 Modifiers: 0x20000000 | [Frame.Keys.onPressed] Key: 0x1000005 Modifiers: 0x20000000 |
Step #4 on Frame | (N/A) | [Frame.Keys.onPressed] Key: 0x1000005 Modifiers: 0x20000000 |
Step #2 on TextField | [TextField.Keys.onPressed] Key: 0x1000004 Modifiers: 0x0 | [TextField.Keys.onPressed] Key: 0x1000004 Modifiers: 0x0 |
Step #3 on TextField | [TextField.Keys.onPressed] Key: 0x1000005 Modifiers: 0x20000000 | [TextField.Keys.onPressed] Key: 0x1000004 Modifiers: 0x20000000 |
Step #4 on TextField | (N/A) | [TextField.Keys.onPressed] Key: 0x1000004 Modifiers: 0x20000000 |
Attachments
For Gerrit Dashboard: QTBUG-104774 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
420502,2 | macOS: Distinguish between return and enter when inserting newlines | dev | qt/qtbase | Status: MERGED | +2 | 0 |
421845,2 | macOS: Distinguish between return and enter when inserting newlines | 6.4 | qt/qtbase | Status: MERGED | +2 | 0 |
421846,2 | macOS: Distinguish between return and enter when inserting newlines | 6.3 | qt/qtbase | Status: MERGED | +2 | 0 |
421848,2 | macOS: Distinguish between return and enter when inserting newlines | tqtc/lts-6.2 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |