diff options
author | Bartlomiej Moskal <bartlomiej.moskal@qt.io> | 2022-09-09 09:55:56 +0200 |
---|---|---|
committer | Bartlomiej Moskal <bartlomiej.moskal@qt.io> | 2022-12-21 04:11:58 +0100 |
commit | 02f1e72d5a18040832a9dd1426b176e5ba769f2f (patch) | |
tree | 6b58164dd214b0e4864e2b95c4fd7af08b1effec /src/widgets | |
parent | 4b892b1034fbae9fe492769c6057c8a6fa3fd5af (diff) |
Android: Set EnterKeyNext as default type for QLineEdit
Behavior of EnterKey for virtual keyboard need to be changed for
QLineEdit. Before this commit, ImeOption was set to IME_ACTION_DONE.
Because of that, setting any text in QLineEdit automatically accept
QDialogs. That was annoying, when more than one QLineEdit need to be
set.
[ChangeLog][Widgets][Android] EnterKey type is now changed from
EnterKeyDefault to EnterKeyNext for virtual keyboard in QLineEdit. It is
done only if the focus can be moved to widget below.
Fixes: QTBUG-61652
Change-Id: I98a7686f9f675fccf0112b8d27d48ad8fd7a887f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index c38f3db7a1..aad75207a1 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1802,6 +1802,22 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e) */ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const { +#ifdef Q_OS_ANDROID + // QTBUG-61652 + if (property == Qt::ImEnterKeyType) { + QWidget *next = nextInFocusChain(); + while (next && next != this && next->focusPolicy() == Qt::NoFocus) + next = next->nextInFocusChain(); + if (next) { + const auto nextYPos = next->mapToGlobal(QPoint(0, 0)).y(); + const auto currentYPos = mapToGlobal(QPoint(0, 0)).y(); + if (currentYPos < nextYPos) + // Set EnterKey to KeyNext type only if the next widget + // in the focus chain is below current QLineEdit + return Qt::EnterKeyNext; + } + } +#endif return inputMethodQuery(property, QVariant()); } |