PHondogo
07/23/2025, 12:16 PMbod
07/23/2025, 12:17 PMPHondogo
07/23/2025, 12:19 PMEkaterina Zaitseva
07/23/2025, 12:36 PMPHondogo
07/23/2025, 12:38 PMEkaterina Zaitseva
07/23/2025, 12:40 PMPHondogo
07/23/2025, 12:47 PMEkaterina Zaitseva
07/23/2025, 1:01 PMPHondogo
07/23/2025, 1:16 PMPHondogo
07/23/2025, 1:17 PMEkaterina Zaitseva
07/23/2025, 1:22 PMPHondogo
07/23/2025, 1:25 PMPHondogo
07/23/2025, 1:35 PMPHondogo
07/23/2025, 1:38 PMPHondogo
07/23/2025, 1:40 PMEkaterina Zaitseva
07/23/2025, 1:44 PMEkaterina Zaitseva
07/23/2025, 1:49 PMBut it is impossible in any case (selected text or not) to hide this context menu when tap outside of it on none focusable area.In this demo it works, it depends on implementation using pointerInput
PHondogo
07/23/2025, 1:50 PMEkaterina Zaitseva
07/23/2025, 1:57 PMvar f1 by remember { mutableStateOf("") }
val focusRequester = remember { FocusRequester() }
val keyboardController = LocalSoftwareKeyboardController.current
val focusManager = LocalFocusManager.current
val textFieldInteractionSource = remember { MutableInteractionSource() }
Box(
modifier = Modifier
.fillMaxSize()
.pointerInput(Unit) {
awaitEachGesture {
val event = awaitPointerEvent()
if (event.type == PointerEventType.Press) {
// Hide keyboard when tapping outside the TextField
keyboardController?.hide()
// Clear focus
focusManager.clearFocus()
}
}
}
) {
OutlinedTextField(
modifier = Modifier
.focusRequester(focusRequester)
.align(Alignment.Center),
value = f1,
onValueChange = { f1 = it },
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(
onDone = {
keyboardController?.hide()
}
),
interactionSource = textFieldInteractionSource
)
}
LaunchedEffect(Unit) {
delay(1000)
focusRequester.requestFocus()
}
PHondogo
07/23/2025, 1:59 PMEkaterina Zaitseva
07/23/2025, 2:00 PMPHondogo
07/23/2025, 10:11 PMEkaterina Zaitseva
07/24/2025, 3:23 PM