mattinger
05/21/2024, 1:04 PMExposedDropdownMenuBox
component not accepting hardware keyboard input? When i run in the emulator, it is unable to accept any hardware keyboard input when the dropdown is active. The soft keyboard works just fine though. Code in đź§µmattinger
05/21/2024, 1:09 PMval allItems = listOf(
"Tyrion Lannister",
"Daenerys Targaryen",
"Jon Snow",
"Sansa Stark",
)
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
) {
var query by remember { mutableStateOf("") }
var active by remember { mutableStateOf(false) }
ExposedDropdownMenuBox(
expanded = active,
onExpandedChange = { active = it }
) {
OutlinedTextField(
modifier = Modifier
.menuAnchor()
.onFocusChanged {
if (it.isFocused) {
active = true
}
},
value = query,
onValueChange = {
query = it
active = true
}
)
val filtered = allItems.filter {
it.contains(query, ignoreCase = true)
}
if (filtered.isNotEmpty()) {
ExposedDropdownMenu(
expanded = active,
onDismissRequest = { active = false }
) {
filtered.forEach {
DropdownMenuItem(
onClick = {
query = it
active = false
},
text = {
Text(it)
}
)
}
}
}
}
}
youssef hachicha
05/22/2024, 7:04 AMmattinger
05/23/2024, 2:46 PM