aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2021-06-08 15:25:09 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2021-06-21 14:48:24 +0000
commitca5b712dfc8e67aece0eb7374ffe5921e2aa45e8 (patch)
treef1ce5d6ac107ff6744bc2fd51c1df1dc81df55ce /src
parentc2e5502d399b2954e7fa33286ac1f1d0546f72cc (diff)
Fix processing of hard Qt::Key_Backspace and Qt::Key_Delete
Even though the virtual keyboard does not support hard keys at the moment, this kind of processing could be possible in the future. In the mean time, fix processing of backspace and delete keys. In particular, if such key is pressed the pre-edit text is not empty: - Reset input method state (should not modify pre-edit) - Clear pre-edit - Return true (to indicate no further processing is required) [ChangeLog] Fix processing of hard backspace and delete keys. Fixes: QTBUG-94017 Pick-to: 5.15 6.1 6.2 Change-Id: I7035f7612e966de6d17d92e754ecd7bdb3a6e530 Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Diffstat (limited to 'src')
-rw-r--r--src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp
index 6a394128..e6bc3fdb 100644
--- a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp
+++ b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp
@@ -519,6 +519,7 @@ bool QVirtualKeyboardInputContextPrivate::filterEvent(const QEvent *event)
QEvent::Type type = event->type();
if (type == QEvent::KeyPress || type == QEvent::KeyRelease) {
const QKeyEvent *keyEvent = static_cast<const QKeyEvent *>(event);
+ const int key = keyEvent->key();
// Keep track of pressed keys update key event state
if (type == QEvent::KeyPress)
@@ -532,7 +533,6 @@ bool QVirtualKeyboardInputContextPrivate::filterEvent(const QEvent *event)
setState(State::KeyEvent);
#ifdef QT_VIRTUALKEYBOARD_ARROW_KEY_NAVIGATION
- int key = keyEvent->key();
if ((key >= Qt::Key_Left && key <= Qt::Key_Down) || key == Qt::Key_Return) {
if (type == QEvent::KeyPress && platformInputContext->isInputPanelVisible()) {
activeNavigationKeys += key;
@@ -547,8 +547,16 @@ bool QVirtualKeyboardInputContextPrivate::filterEvent(const QEvent *event)
#endif
// Break composing text since the virtual keyboard does not support hard keyboard events
- if (!preeditText.isEmpty())
- commit();
+ if (!preeditText.isEmpty()) {
+ if (type == QEvent::KeyPress && (key == Qt::Key_Delete || key == Qt::Key_Backspace)) {
+ reset();
+ Q_Q(QVirtualKeyboardInputContext);
+ q->clear();
+ return true;
+ } else {
+ commit();
+ }
+ }
}
#ifdef QT_VIRTUALKEYBOARD_ARROW_KEY_NAVIGATION
else if (type == QEvent::ShortcutOverride) {