diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-09-21 17:05:26 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-22 08:42:34 +0000 |
commit | a4e41e7ac42f835015bdca395a34e5bca7eda86c (patch) | |
tree | e09ef3835ddf5bdace5b7c16d74e38d36100ea92 | |
parent | f887a8eab25fd2cf3beee7527198f41ac15c8fcd (diff) |
macOS: Don't re-send key event through input method on focus object change
In 0c2ca26cd9583092f3ade7b18bc2423336a6202b we started re-sending the
key event through the input method when we detected a focus object change,
to support the use-case of QAbstractItemView opening an editor and changing
focus in response to the first QEvent::InputMethod event.
Unfortunately this doesn't work as a general approach, because we don't
know what the reason was for the change in focus object. For example,
a client might respond to a Qt::Key_Return press by changing the focus
to the next input element, and re-sending the key event would in that
case insert a new-line in the new focus object -- counter to the
expectations of the client.
Since we can't know the reason for the changed focus object we can't
assume re-sending the key event is safe.
Task-number: QTBUG-54848
Fixes: QTBUG-96726
Change-Id: Iea8b166385925cd1a05ef62d5cf763638d9f8a67
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ab4fb3ffd40c0bf694161d955d4a58602b9f1a4c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_keys.mm | 9 |
1 files changed, 0 insertions, 9 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_keys.mm b/src/plugins/platforms/cocoa/qnsview_keys.mm index c8c6fb320a..dbcab6c6d1 100644 --- a/src/plugins/platforms/cocoa/qnsview_keys.mm +++ b/src/plugins/platforms/cocoa/qnsview_keys.mm @@ -104,15 +104,6 @@ qCDebug(lcQpaKeys) << "Interpreting key event for focus object" << focusObject; m_currentlyInterpretedKeyEvent = nsevent; [self interpretKeyEvents:@[nsevent]]; - - // If the receiver opens an editor in response to a key press, then the focus will change, the input - // method will be reset, and the first key press will be gone. If the focus object changes, then we - // need to pass the key event to the input method once more. - if (qApp->focusObject() != focusObject) { - qCDebug(lcQpaKeys) << "Interpreting key event again for new focus object" << qApp->focusObject(); - [self interpretKeyEvents:@[nsevent]]; - } - m_currentlyInterpretedKeyEvent = 0; // If the last key we sent was dead, then pass the next |