1

I have an OutlinedTextField that should only accept CAPITAL characters. I have defined the composable like this:

val keyboardController = LocalSoftwareKeyboardController.current
var textFieldValue by remember { mutableStateOf(TextFieldValue("")) }
val focusRequester = remember {
    textFieldValue = textFieldValue.copy(selection = TextRange(textFieldValue.text.length))
    FocusRequester()
}
OutlinedTextField(
    label = {
        Text(label)
    },
    value = textFieldValue,
    onValueChange = {
        textFieldValue = it
        // handle value change...
    },
    keyboardOptions = KeyboardOptions.Default.copy(
        imeAction = ImeAction.Done,
        capitalization = KeyboardCapitalization.Characters,
        autoCorrect = false
    ),
    keyboardActions = KeyboardActions(onDone = {
        keyboardController?.hide()
        // handle done
    }),
    modifier = Modifier
        .fillMaxWidth()
        .padding(bottom = 16.dp)
        .focusRequester(focusRequester)
)

This works like a charm on the emulator. However, on my Galaxy Watch 6 Classic, the keyboard loads in lowercase mode the first time, and text field does not accept any text. If I dismiss the keyboard, and trigger it again, everything works perfectly. Am I doing something wrong here? I am using package androidx.compose.material3.OutlinedTextField

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.