d

    Denis

    1 year ago
    I need to detect touch events and change some state with respect to up and down motion events. The next code (see the thread) works well with simple taps, but if I tap with 3 fingers, it adds only "Down" event, but no "Up". What could be the problem? Do I need to use something else besides
    pointerInteropFilter
    ?
    var log by remember { mutableStateOf(listOf<String>()) }
    Surface(
        color = MaterialTheme.colors.background,
        modifier = Modifier.fillMaxSize().pointerInteropFilter {
            when (it.action) {
                MotionEvent.ACTION_DOWN -> log = log + "Down"
                MotionEvent.ACTION_UP -> log = log + "Up"
                MotionEvent.ACTION_MOVE -> log = log + "Move"
                else -> false
            }
            true
        }
    ) { Column { for (l in log.takeLast(20)) Text(l) } }
    Kotlin 1.4.21, Compose 1.0.0-alpha09.