I am trying to make a composable draggable but als...
# compose
a
I am trying to make a composable draggable but also clickable, how can I do proper click routing? Code in 🧵
Currently the drag works perfectly with the following modifier:
Copy code
composed {
    pointerInput(Unit) {
        coroutineScope {
            while (true) {
                val pointerId = awaitPointerEventScope { awaitFirstDown().id }
                awaitPointerEventScope {
                    horizontalDrag(pointerId) {
...
But when I add a clickable modifier, the click will always be detected, but the drag will never trigger anymore. Is there a way to combine a clickable with a drag (on clearing the touch slop)?
z
This works for me 🙂
Copy code
.pointerInput(Unit) {
    detectDragGestures { change, (x, y) ->
        change.consumeAllChanges()

        // Some drag stuff
    }
}
.clickable(
    onClick = { 
        // Some click stuff
    } 
)
🔥 2
a
This works fantastically, thanks a lot @Zoltan Demant
👍🏽 1
I will mention you in a code comment 😄
😂 1
🦜 1
🥰 1
c
I do this too! Ian Lake, Adam Powell, Zach Klippenstein, Doris Liu, Jim Sproch, and Albert Chang are all over my code comments. A bunch of others too!