From 0dc58ccf209e1f8840bba350cfeddef73ee22fde Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Mon, 28 Sep 2026 15:26:08 -0300 Subject: [PATCH] desktop: run the primary action on Enter in the passphrase screens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The unlock screen and the first-run passphrase setup required a mouse click on the button; Enter did nothing, which every password prompt gets wrong. Preview-key handling on the lock screen scaffold maps Enter (and numpad Enter) to the primary action — a no-op while a check is in progress or the field is empty, so an empty submit cannot spam the wrong-passphrase error. --- .../nostrsigner/desktop/ui/UnlockScreen.kt | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/desktop/src/main/kotlin/com/greenart7c3/nostrsigner/desktop/ui/UnlockScreen.kt b/desktop/src/main/kotlin/com/greenart7c3/nostrsigner/desktop/ui/UnlockScreen.kt index 08b962f0..e19c8cb1 100644 --- a/desktop/src/main/kotlin/com/greenart7c3/nostrsigner/desktop/ui/UnlockScreen.kt +++ b/desktop/src/main/kotlin/com/greenart7c3/nostrsigner/desktop/ui/UnlockScreen.kt @@ -22,6 +22,11 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.input.key.Key +import androidx.compose.ui.input.key.KeyEventType +import androidx.compose.ui.input.key.key +import androidx.compose.ui.input.key.onPreviewKeyEvent +import androidx.compose.ui.input.key.type import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.PasswordVisualTransformation @@ -53,7 +58,10 @@ fun UnlockScreen() { } } - LockScreenScaffold(subtitle = Strings.get("d_locked", language)) { + LockScreenScaffold( + subtitle = Strings.get("d_locked", language), + onEnter = { submit() }, + ) { OutlinedTextField( value = passphrase, onValueChange = { passphrase = it }, @@ -114,7 +122,10 @@ fun PassphraseSetupScreen() { } } - LockScreenScaffold(subtitle = Strings.get("d_passphrase_desc", language)) { + LockScreenScaffold( + subtitle = Strings.get("d_passphrase_desc", language), + onEnter = { submit() }, + ) { OutlinedTextField( value = passphrase, onValueChange = { passphrase = it }, @@ -158,9 +169,27 @@ fun PassphraseSetupScreen() { @Composable private fun LockScreenScaffold( subtitle: String, + onEnter: (() -> Unit)?, content: @Composable ColumnScope.() -> Unit, ) { - Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Box( + Modifier + .fillMaxSize() + .onPreviewKeyEvent { event -> + // Enter (or numpad enter) runs the primary action, the way + // every password prompt behaves. + if (onEnter != null && + event.type == KeyEventType.KeyUp && + (event.key == Key.Enter || event.key == Key.NumPadEnter) + ) { + onEnter() + true + } else { + false + } + }, + contentAlignment = Alignment.Center, + ) { Column( Modifier.widthIn(max = 480.dp).padding(24.dp), horizontalAlignment = Alignment.CenterHorizontally,