https://kotlinlang.org logo
#compose
Title
# compose
m

mattinger

12/04/2023, 3:40 PM
Hi all, so I have a Popup window, which has a few text fields in it. However, when i click in the text fields, the keyboard does not come up. I’ve been searching around and one or two places on stack overflow have mentioned that their keyboard pops up, but it’s behind the popup window. Does anyone know anything about this? (sample code in thread)
Copy code
@Composable
@Preview(showBackground = true)
fun KeyboardIssuePreview() {
    MaterialTheme {
        Surface(modifier = Modifier.fillMaxSize(), color = Color.White) {
            val popupVisible = remember { mutableStateOf(false) }
            Column {
                Button(
                    onClick = {
                        popupVisible.value = true
                    }
                ) {
                    Text(text = "Open Popup")
                }
            }


            if (popupVisible.value) {
                val textValue = remember { mutableStateOf("") }
                Popup(alignment = Alignment.Center) {
                    Surface(modifier = Modifier.fillMaxSize()) {
                        Column(modifier = Modifier.padding(16.dp)) {
                            OutlinedTextField(
                                value = textValue.value,
                                onValueChange = { textValue.value = it })
                        }

                    }
                }
            }
        }
    }
}
3 Views