#Is there a specific channel for Compose
1 messages · Page 1 of 1 (latest)
idk just posting it here, is anyone facing similar issue post the latest update : https://stackoverflow.com/q/67687674/6462865 the onValueChange lambda is not getting invoked on my textfield if the keyboard type is set to number, its pretty strange, if anyone here encountered similar issue please suggest a fix or other suggestions.
The special character in the same keyboard is working as expected just not the numbers.
Hi @native belfry , you want the normal keyboard to open in the area where text will be entered. Right?
I think we can check this by putting an if-else check in the keyboardOptions of the TextField. Accordingly, we can change it to KeyboardType.Number or KeyboardType.Text.
@Composable
fun MyTextField() {
var isNumericKeyboard by remember { mutableStateOf(true) }
var myTextValue by remember { mutableStateOf("") }
Column {
TextField(
value = textValue,
onValueChange = { newValue ->
myTextValue = newValue
},
keyboardOptions = {
KeyboardOptions(keyboardType = if (isNumericKeyboard) KeyboardType.Number else KeyboardType.Text)
}
)
Button(onClick = {
isNumericKeyboard = false
}) {
Text("Hello!")
}
}
}
I don't know if it will work correctly but you can try it.
And btw there is no specific Compose channel here. You can write this channel your question about Compose.
thanks
the thing is if the keyboard type is set to numeric the textfield does not respond to numbers.
This is the case.
i tried it with BTF and still the same result, do share your thoughts guys.
the video didn't work for me
I'll search. If I find something I'll write again
thanks
it seems to be an extreme isolated bug have rolled back to the 2023.10 bom and it works as expected.
So you solved the problem?
In Compose, InputInteractionState can be used to track the interaction state that is triggered when you click or navigate away from a TextField. This status can be used to monitor whether a TextField has focus. If the TextField has focus and the user presses a key, it can track that state.
val interactionSource = remember { MutableInteractionSource() }
val isFocused by interactionSource.collectIsFocusedAsState()
val textValue by remember { mutableStateOf(TextFieldValue("")) }
TextField(
value = textValue,
onValueChange = {
textValue = it
},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
interactionSource = interactionSource
)
if (isFocused) {
// If the TextField has focus, you can do something here.
}
maybe this could work
thanks but it seems to be an isolated issue can't even raise a ticked as i may have to share the entire code base, but as you might have noticed on the video the keyboard is accepting anything but number, so what worked for me is to rollback to the old working version, probably this will get fixed in the upcoming updates. Thanks @native sentinel for your inputs and efforts 