JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.24k stars 1.11k forks source link

Need to tap the touchpad thrice for double click action when using combined clickable. However, Button clicks are only required to clicked twice. #4871

Open Akhil-Hothi opened 1 month ago

Akhil-Hothi commented 1 month ago

Bug Description I have a device with a touchpad (windows laptop's trackpad) along with two real buttons for left and right mouse click. I noticed that when I tried to implement double click behaviour, I actually need to tap thrice on touchpad. I can perform double click just by clicking twice the hardware buttons, but not the tap gesture on tap pad.

            .combinedClickable(
                onClick = { /* Do nothing */ },
                onDoubleClick = { toggleMaximizeRestore() },
                // Default parameter to not show ripple
                indication = null, // No ripple effect
                interactionSource = remember { MutableInteractionSource() } // Ensures no interaction feedback
            )

Initially I thought that click timing is problem but now I know it's not the time gap, rather It's just that I need to tap thrice instead of twice. In my case, when I tap thrice it works fine.

Affected platforms

Versions

To Reproduce Steps to reproduce the behavior:

  1. Run this code snippet:

    @Composable
    fun BugReproduction() {
        Row(
            modifier = Modifier
                .shadow(
                    elevation = 12.dp,
                    spotColor = Color(0x40000000),
                    ambientColor = Color(0x40000000)
                )
                .fillMaxWidth()
                .height(32.dp)
                .background(color = Color(0xFFD0E3FF)) // Static background color
                .padding(start = 6.dp)
                .pointerInput(Unit) {
                    detectDragGestures { change, dragAmount ->
                        change.consume() // Consume the gesture event
                        //Do something
    
                    }
                }
                .combinedClickable(
                    onClick = { /* Do nothing */ },
                    onDoubleClick = { toggleMaximizeRestore() },
                    // Default parameter to not show ripple
                    indication = null, // No ripple effect
                    interactionSource = remember { MutableInteractionSource() } // Ensures no interaction feedback
                ),
         )
    }
    fun toggleMaximizeRestore() {
       if (isMaximized) {
           isMaximized = !isMaximized
           window.setSize(screenWidth, adjustedHeight)
           window.setLocation(0, 0)
       } else {
           isMaximized = true
           currentWindowX = startWindowLocX
           currentWindowY = startWindowLocY
           window.setSize((screenWidth / 1.125f).toInt(), (screenWidth * 9 / (16*1.125f).toInt())) // Default size when restoring
           window.setLocation(currentWindowX.value.toInt(), currentWindowY.value.toInt())
       }
    }
    
  2. Try double tapping on the light blue color bar, first with touchpad and then with buttons.
  3. Just like step 2, try tapping thrice.

Expected behavior It should be consistent for both, double tapping touchpad and clicking hardware buttons.

mazunin-v-jb commented 1 month ago

Hello, @Akhil-Hothi! Have you tried to run your app on another physical device with a touchpad? And does this issue happen in other apps on your machine as well?

Akhil-Hothi commented 1 month ago

Yes, I have tried it on a different Asus Laptop. Despite the laptop model being different, issue remains same as mentioned earlier in the initial post.

In this laptop model, the touchpad is little different, it doesn't have separate visible buttons/keys from outside but from inside it also has two pressable buttons for left and right click at the bottom part of the touchpad.

MatkovIvan commented 3 weeks ago

@igordmn most likely it's about https://github.com/JetBrains/compose-multiplatform-core/pull/1341

igordmn commented 3 weeks ago

@igordmn most likely it's about https://github.com/JetBrains/compose-multiplatform-core/pull/1341

I have investigated this, and this is just about unsuitable ViewConfiguration for touchpad.

I am experimenting with different values with different devices/OS'es now. The Android ported implementation doesn't always suit them.

Akhil-Hothi commented 1 week ago

How can I know when the issue is fixed?