https://kotlinlang.org logo
#compose
Title
# compose
v

Vsevolod Ganin

12/31/2020, 7:41 PM
How to combine different gesture detectors using
pointerInput
? My goal is combine zooming (1), scrolling (2) and drag-n-drop (3) on the same composable. 1 and 2 are available with
detectMultitouchGestures
. 3 could be done using
detectTapGestures
+
detectDragGestures
I guess. The idea is to listen to gesture trigger first and then give full control to corresponding gesture routine. Honestly I don’t how to approach this, the examples don’t cover this it seems
r

rsktash

12/31/2020, 8:21 PM
You can use mutablestate which will store all gesture states
v

Vsevolod Ganin

12/31/2020, 9:57 PM
The problem is that detector functions are suspending. If I suspend on one detector, I can’t use another
I’m back from holidays and I want to share a bit of what I’ve learned. As it turns out
detect*
suspending functions are not really suitable for mixing with anything now as they are looping inside indefinitely waiting for next unconsumed touch down. So they cannot be used to continue processing of a gesture in the middle either. One option I can see is to use internals of these functions and try to combine them. @Shep Shapard what do you think? Maybe we should have detectors additionally decoupled in
await
-like functions? Like
awaitLongTap
,
awaitMultitouchGesture
, etc. so it’s easy to combine parts of them.
4 Views