Vivek Sharma
02/24/2021, 8:50 PMpressIndicatorGesture
, I am using this to immitate that :
Modifier.pointerInput(Unit) {
detectTapGestures(
onLongPress = { doingSomething }
)
}
how can I listen when you have left/cancel the long press?Alexandre Elias [G]
02/24/2021, 11:23 PMonPress
handler invoking awaitRelease
, or more simply, just writing the code after detectTapGestures
returns may work for you.Alexandre Elias [G]
02/24/2021, 11:23 PMvar didLongPress = false
and set it in your long-press handler in order to distinguish long presses from other types of pressesVivek Sharma
02/25/2021, 10:26 AMModifier.pointerInput(Unit) {
detectTapGestures(
onLongPress = {
doingSomething(true)
},
onPress = {
doingSomething(true)
if (this.tryAwaitRelease()) {
doingSomething(false)
}
}
)
}
I used tryAwaitRelease()
as it returned me a boolean value to check when gesture is cancelled