From 492796e8f252736ec0c77ee928228e86a397e09c Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 19 Nov 2020 19:06:34 +0100 Subject: [PATCH] Fix the autorepeating to ignore keys on printable keys only --- .../modules/Common/Form/DroppableTextArea.qml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/linphone-app/ui/modules/Common/Form/DroppableTextArea.qml b/linphone-app/ui/modules/Common/Form/DroppableTextArea.qml index 29c1e3e70..b35c77cfc 100644 --- a/linphone-app/ui/modules/Common/Form/DroppableTextArea.qml +++ b/linphone-app/ui/modules/Common/Form/DroppableTextArea.qml @@ -80,16 +80,20 @@ Item { property var isAutoRepeating : false // shutdown repeating key feature to let optional menu appears and do normal stuff (like accents menu) Keys.onReleased: { - if(isAutoRepeating){// In a repeat session, we don't print the key - isAutoRepeating = false - if(event.text !== '')// Remove the previous character - textArea.remove(textArea.text.length-1, textArea.text.length) - } + if( event.isAutoRepeat){// We begin or are currently repeating a key + if(!isAutoRepeating){// We start repeat. Check if this is an "ignore" character + if(event.key > Qt.Key_Any && event.key <= Qt.Key_ydiaeresis)// Remove the previous character if it is a printable character + textArea.remove(cursorPosition-1, cursorPosition) + } + }else + isAutoRepeating = false// We are no more repeating. Final decision is done on Releasing } Keys.onPressed: { if(event.isAutoRepeat){ - isAutoRepeating = true - event.accepted = true + isAutoRepeating = true// Where are repeating the key. Set the state. + if(event.key > Qt.Key_Any && event.key <= Qt.Key_ydiaeresis){// Ignore character if it is repeating and printable character + event.accepted = true + } }else if (event.matches(StandardKey.InsertLineSeparator)) { insert(cursorPosition, '') } else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {