Go to file
Tor Arne Vestbø 705665957b macOS: Remove hard-coded logic for determining if key event has text
The normal flow for a keyDown event when sent to a text input enabled
view (NSTextInputClient), is that it's sent through interpretKeyEvents,
which in turn goes through the input methods, and result in either
composing (marking) text, inserting text, or executing a text editing
command such as moving the cursor to the beginning of the line.

  https://apple.co/3qDhwNb

In our case, we prefer to treat "simple" text insertion (non-composed
text) outside of the Qt input method protocol, and send these as normal
key events instead. The same applies when a key event results in a text
editing command that we don't handle.

The problem is that in the latter case, the key event would contain the
text that resulted from e.g. ⌘+K, or one of the function or arrow keys,
which in many cases would not be suitable for inserting into a text
field by a naive client that trusted the text property of the QKeyEvent.

To work around this two exceptions were added; first in 4dbce2a469
to ignore text when inside the U+F700-U+F8FF unicode range (arrow keys,
function keys, etc), and second in 933fab137d to ignore text for
events that had one or both of the control or command modifiers.

Unfortunately this hard-coded logic was not taking into account that
some keyboard layouts may produce text that match these exceptions,
for example ^⌥+ю with a Russian keyboard layout should result in
inserting a period.

Instead of continuing to add hard-coded exceptions to this logic,
(for example by only filtering out single-modifier events), we
instead use the information that the text input system gives us
via doCommandBySelector to decide whether the key event should
have text or not.

Note: We have similar workarounds for detecting text that is not
suitable for text insertion in other places of Qt, for example in
QInputControl::isAcceptableInput(), but since we can't assume the
client uses QInputControl for their text input needs we need to
filter out the text earlier than that.

Fixes: QTBUG-106393
Task-number: QTBUG-36281
Task-number: QTBUG-35734
Pick-to: 6.4
Change-Id: I7769098cba1c605f6fdb6b23964eb614578724bb
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-17 21:37:20 +02:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
bin Minor fixes for qt-configure-module 2022-06-27 17:55:19 +02:00
cmake CMake: Fix _qt_is_test_executable assignment for tests 2022-09-17 00:30:39 +02:00
coin Coin: Add core count config 2022-09-12 10:37:42 +00:00
config.tests Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc CMake: Add reference documentation for QT_IOS_LAUNCH_SCREEN 2022-09-02 17:00:23 +02:00
examples Pass a parent pointer to the Animation instance to avoid memory leak 2022-09-15 17:57:54 +02:00
lib
libexec Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
LICENSES Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
mkspecs Move tvOS and watchOS mkspecs to unsupported directory 2022-09-13 18:19:53 +02:00
qmake Move qVersion() from qglobal.h to qlibraryinfo.h 2022-09-01 13:26:30 +02:00
src macOS: Remove hard-coded logic for determining if key event has text 2022-09-17 21:37:20 +02:00
tests Fix flaky FP32x4 test 2022-09-16 21:02:31 +02:00
util Fix trivial typo in cldr.py doc-string 2022-09-14 17:46:39 +02:00
.cmake.conf Bump version to 6.5.0 2022-06-06 13:23:59 +03:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Assume qhelpgenerator in libexec instead of bin 2021-11-08 19:27:32 +01:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag
CMakeLists.txt Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00
conanfile.py Conan: Do not force 'qt_host_path' usage in cross-build context 2022-06-22 18:18:42 +03:00
config_help.txt Add -disable-deprecated-up-to parameter to configure script 2022-08-19 23:52:05 +02:00
configure Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
configure.bat Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
configure.cmake wasm: add support for building Qt as shared libraries 2022-08-30 22:11:01 +10:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
qt_cmdline.cmake Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00
sync.profile Remove deprecated qgl.h from sync.profile 2022-06-11 00:42:13 +02:00