Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mouseClickable shouldn't fire click when detectTransformGestures on parent handles gesture #1779

Closed
jimgoog opened this issue Feb 1, 2022 · 2 comments
Assignees
Labels
bug Something isn't working desktop input Touch, mouse, keyboard input related
Milestone

Comments

@jimgoog
Copy link
Collaborator

jimgoog commented Feb 1, 2022

Drag your mouse over the following text. Observe that mouse click fires on the child despite the fact a pan gesture was detected by the parent. Issue appears to be on the desktop side in mouseClickable . We normally/should solve this by watching for consumed events while waiting for the "up". See waitForUpOrCancellation as an example.

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.detectTransformGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.mouseClickable
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application

@OptIn(ExperimentalFoundationApi::class)
fun main() = application() {
    Window(onCloseRequest = ::exitApplication) {
        Box(Modifier.fillMaxSize().pointerInput(Unit) { detectTransformGestures { centroid, pan, zoom, rotation -> println("parent detected gesture $centroid $pan $zoom $rotation") }}) {
            Box(Modifier.fillMaxSize().mouseClickable { println("child click detected") }) {
                Text("Just some content")
            }
        }
    }
}

cc @igordmn @olonho

@igordmn
Copy link
Collaborator

igordmn commented Feb 2, 2022

Fixed in JetBrains/compose-multiplatform-core#178.

By the way, mouseClickable is a temporary workaround. It still doesn't support auto-hover, auto-action on Enter key, mouse slop detection.

Also it doesn't support detection of simultaneously pressed buttons (right click when the left button is pressed, for example).

We tried to introduce info about pressed buttons in the past into common clickable. We plan to return to this feature someday, and deprecate mouseClickable

@igordmn igordmn added this to the 1.1 milestone Feb 2, 2022
@igordmn igordmn added bug Something isn't working desktop input Touch, mouse, keyboard input related wait for build labels Feb 2, 2022
@akurasov
Copy link
Contributor

Fixed in 1.1.0-alpha04

igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Mar 28, 2022
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Mar 30, 2022
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Apr 4, 2022
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Apr 18, 2022
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Jun 2, 2022
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Jun 27, 2022
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Aug 18, 2022
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Aug 18, 2022
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Oct 26, 2022
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Nov 16, 2022
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Jan 13, 2023
MatkovIvan pushed a commit to MatkovIvan/compose-multiplatform that referenced this issue May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working desktop input Touch, mouse, keyboard input related
Projects
None yet
Development

No branches or pull requests

3 participants