When i set keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) or even KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number), the onValueChange callback is not triggerd.
Versions:
software | version |
---|---|
Compose compiler | 1.4.6 |
Compose UI | 1.4.3 |
Kotlin | 1.8.2 |
Kotlin code:
import android.util.Log
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.OutlinedTextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.text.input.KeyboardType
@Composable
fun TestNumberInput() {
var numbers by remember {
mutableStateOf("")
}
OutlinedTextField(
value = numbers,
onValueChange = {
Log.i("TEST", "numbers: $numbers")
numbers = it
},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
)
}
There is already a question on stackoverflow about this problem but the cause seems to come from somewhere else then the problem i have.