Hi, how to set click event as not consumed so that...
# compose
l
Hi, how to set click event as not consumed so that long pressing on it will repeat click action until release? As there is no boolean return for onLongPress in detectTapGestures.
Copy code
Modifier.pointerInput(Unit) {
                detectTapGestures(
                    onPress = { onClick() },
                    onLongPress = { onClick() }
                )
            }
So I implemented this. Please let me know if there are better way.
Copy code
val interactionSource = remember { MutableInteractionSource() }
val isPressed by interactionSource.collectIsPressedAsState()

LaunchedEffect(isPressed) {
    while (isPressed) {
        delay(100)
        onClick()
    }
}

Button(modifier = Modifier.clickable(interactionSource = interactionSource))
z
Copy code
Modifier.pointerInteropFilter { event ->
                when(event.action) {
        MotionEvent.ACTION_DOWN -> {
            //initial state when user clicked
        }

        MotionEvent.ACTION_MOVE -> {
            //user is keeping press component
        }

        MotionEvent.ACTION_UP -> {
            //when user left press
        }
    }
                true
            }