Fix the autorepeating to ignore keys on printable keys only

This commit is contained in:
Julien Wadel 2020-11-19 19:06:34 +01:00
parent 01c8f7ca00
commit 492796e8f2

View file

@ -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) {