'pointerInput of Modifier takes no actions

I need a Card() Composable with a normal press and a long press functionality for a custom Card Composable. The thing is Card() has its own value called onClick = {} and its working fine but has no option for a long press. So I researched if theres a way to handle it without styling my whole own Card Composable and there you go, the Modifier has an own function called Modifier.pointerInput which Ive tried but unfortunately it doesnt work. Do I maybe use it wrong or is this functionality not available in Card()?

This is my implementation (Adapted from the Android Docs):

Card(
  modifier = Modifier.pointerInput(Unit) {
    detectTapGestures(
      onPress = { clickable() },
      onLongPress = { longClickable() }
  }
)

Am I maybe supposed to deactivate the onClick functionality of Card?



Solution 1:[1]

Just add a size modifier. This code works for me:

Card(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.Magenta)
            .pointerInput(Unit) {
                detectTapGestures(
                    onPress = { Log.d("mlogs", "LoginScreen:  onPress") },
                    onLongPress = { Log.d("mlogs", "LoginScreen: onLongPress") })
            }
        , content = {}
    )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Edgar Khimich