2

I want to detect tap gesture in LazyColumn and long press gesture in items:

LazyColumn(
    modifier = Modifier.pointerInput(Unit) {
        detectTapGestures(onTap = { /* do something */})
    }
) {
    items(items) {
        ListItem(
            modifier=Modifier.pointerInput(Unit) {
                detectTapGestures(onLongPress = { /* do something else */})
            }
        )
    }
}

Obviously ListItem will consume all gestures. So my question is how to detect tap gestures without consuming them?

FishHawk
  • 414
  • 4
  • 11
  • 1
    Why don't you detect both gestures on `ListItem`? If you have padding on `ListItem` or space between items you can detect tap on `LazyColumn` and detect tap on items and act as it's on LazyColumn, doesn't this work? Your other option is write detectTapGestures by removing specific `upOrCancel.consume()` code – Thracian Jul 07 '22 at 10:04
  • This is because I need the offset relative to the LazyColumn in onTap function. Furthermore, I need to detect more gesture to handle the scaling of the LazyColumn. Anyway, thanks for advice. But as far as I know, even if up event is not consumed, LazyColumn will not detect gesture as long as down event is consumed. – FishHawk Jul 07 '22 at 11:14

1 Answers1

1

you can use awaitRelease,i hope the problem is solved

  • 1
    I've solved it with hacky. I'll check your answer when I have time to refactor this part, but it may be a long time, sorry about that. – FishHawk Nov 06 '22 at 11:16