lockscreen: handle backspace and enter key when switching from keypad

This fixes an issue were pressing the backspace or enter key on the keyboard when using the keypad, unexpected results occurred.
This also fixes an issue were if only one key is typed from the initial lockscreen view, the backspace key would not actually do anything.
This commit is contained in:
Micah Stanley 2024-11-21 13:36:29 +00:00 committed by Devin Lin
parent 70ec403a55
commit abb9b963f0

View file

@ -73,6 +73,11 @@ Rectangle {
function keyPress(data) {
if (!lockScreenState.waitingForAuth) {
if (data === "\x08") { // Handle backspace
root.backspace();
} else if (data === "\r") { // Handle enter
root.enter();
} else {
root.lockScreenState.resetPinLabel();
root.previewCharIndex = lockScreenState.password.length;
@ -82,6 +87,7 @@ Rectangle {
letterTimer.restart();
}
}
}
// HACK: we have to open the virtual keyboard after a certain amount of time or else it will close anyway
Timer {
@ -146,8 +152,8 @@ Rectangle {
} else if (text.length > 0) { // key enter
root.keyPress(text.charAt(text.length - 1));
}
prevText = text;
}
prevText = text;
externalEdit = false;
}
}