https://kotlinlang.org logo
m

Michał Jurczyk

09/01/2020, 9:08 PM
Hey 👋 Does Compose support drag and drop? I have a
LazyColumn
of cards and want to drag'n'drop items onto the cards from a picker. In native UI I used to do it with
setOnDragListener
listening to
ACTION_DROP
and
clipData
🤔
I was thinking about using an invisible
AndroidView
composable in each card, with all the listeners, but wanted to make sure I am not missing something obvious before I started hacking 😅
m

Michał Jurczyk

09/02/2020, 2:25 PM
Yeah, but this seems to be mostly for local drags, with no interactions between the dragged
Composable
and the one below 🤔 And there is no drop callback, only the
onStop
on the dragged
Composable
, with offset as param. I guess I could do some calculation based on the offset, but no idea where to take it from there, especially in LazyColumn 🤔
z

Zach Klippenstein (he/him) [MOD]

09/02/2020, 2:31 PM
Would be good to have system drag/drop support from the clipboard API too, although i wonder if that’s a feature anyone actually uses.
m

Michał Jurczyk

09/02/2020, 2:35 PM
Good point, this is one of these features that feel most useful for press demos 😅
Anyway, thanks a lot for the tip ☺️ I will try diving a bit deeper into it and if I can not get it to work, the AndroidView placeholder it is for now.
z

Zach Klippenstein (he/him) [MOD]

09/02/2020, 2:40 PM
Couldn’t hurt to file an issue for drag/drop support while you’re at it. Issue tracker link is in the channel description.
👍 1
2 Views