From 23df2c9922c44a45be41cac7c4b767f3d77c5818 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Mon, 28 Sep 2026 15:52:34 -0300 Subject: [PATCH] desktop: focus the passphrase field when the lock screen is shown The unlock and first-run setup screens opened with no input focused, forcing a mouse click before typing. Attach a FocusRequester to the passphrase field and request focus on composition so the screen is type-and-Enter ready immediately (pairs with the Enter-to-submit handler from the previous commit). --- .../nostrsigner/desktop/ui/UnlockScreen.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 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 e19c8cb1..fbce930b 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 @@ -14,6 +14,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -22,6 +23,8 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.KeyEventType import androidx.compose.ui.input.key.key @@ -42,6 +45,9 @@ fun UnlockScreen() { var passphrase by remember { mutableStateOf("") } var error by remember { mutableStateOf(null) } var working by remember { mutableStateOf(false) } + val passphraseFocus = remember { FocusRequester() } + + LaunchedEffect(Unit) { passphraseFocus.requestFocus() } fun submit() { if (passphrase.isEmpty() || working) return @@ -69,7 +75,7 @@ fun UnlockScreen() { singleLine = true, visualTransformation = PasswordVisualTransformation(), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password), - modifier = Modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth().focusRequester(passphraseFocus), ) error?.let { Spacer(Modifier.height(8.dp)) @@ -97,6 +103,9 @@ fun PassphraseSetupScreen() { var confirm by remember { mutableStateOf("") } var error by remember { mutableStateOf(null) } var working by remember { mutableStateOf(false) } + val passphraseFocus = remember { FocusRequester() } + + LaunchedEffect(Unit) { passphraseFocus.requestFocus() } fun submit() { if (working) return @@ -133,7 +142,7 @@ fun PassphraseSetupScreen() { singleLine = true, visualTransformation = PasswordVisualTransformation(), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password), - modifier = Modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth().focusRequester(passphraseFocus), ) Spacer(Modifier.height(8.dp)) OutlinedTextField(