Marcin Środa
08/18/2021, 12:23 PMMarcin Środa
08/18/2021, 12:23 PMMarcin Środa
08/18/2021, 12:24 PMcombinedClickable
is not working as I expectedMarcin Środa
08/18/2021, 12:25 PMTash
08/18/2021, 8:22 PMMarcin Środa
08/19/2021, 9:48 AMBox(
modifier = Modifier.background(Color.Green)
.padding(16.dp)
.pointerInput(Unit) {
detectTapGestures(
onLongPress = {
Timber.e("onLongPress")
}
)
},
){
Box(
modifier = Modifier.background(Color.Red)
.fillMaxSize()
.pointerInput(Unit) {
detectTapGestures(
onPress = {
Timber.e("onPress Start")
val success = tryAwaitRelease()
Timber.e("onPress Stop $success")
}
)
},
)
}
I mean I want to pass the event down, to the parent. So when I’ll execute long press on RED box and there’s no onLongPress callback I want to pass the event to the GREEN box and use it. Right now the event is consumed.Marcin Środa
08/19/2021, 10:00 AMChachako
08/19/2021, 10:13 AMperformClick
, there seems to be no similar approach in Compose.Marcin Środa
08/19/2021, 11:20 AMMarcin Środa
08/23/2021, 1:17 PMmatvei
08/23/2021, 1:29 PMdetectTapGestures
implementation. detect*Gestures
methods are terminal methods that allow for a predefined set of features corresponding to a gesture. Tap gestures consume down even, that being for a press, tap or long press. When the down even is consumed, parents of this node who are waiting for a down Unconsumed event won't be notified with this, therefore not triggering their callbacks. It would be surprising for button to allow parents to long-click through it by default.
You can write your own gesture detector though, using different gesture passes or consumed/unconsumed logic you should be able to achieve your desired behaviour.Mikael Alfredsson
01/10/2022, 9:08 PMmatvei
01/11/2022, 12:03 PMSince a consumed event wont be sent to the parent (if I read the above correctly)Every event will be sent fully through the pipeline from the root to the positively hit-tested child regarless of the comsumption. The event that is consumed by a child will be marked as such, that's it. For your problem it seems like you need to listen for any event that changed from down to up (lifted finger, mouse, etc) on the final pass, regardless of the comsumption
Mikael Alfredsson
01/11/2022, 12:08 PMmatvei
01/11/2022, 12:28 PM