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

detectDragGesture is unusable on Desktop #343

Closed
LAP2 opened this issue Feb 2, 2021 · 6 comments
Closed

detectDragGesture is unusable on Desktop #343

LAP2 opened this issue Feb 2, 2021 · 6 comments
Assignees
Labels
bug Something isn't working desktop input Touch, mouse, keyboard input related

Comments

@LAP2
Copy link
Contributor

LAP2 commented Feb 2, 2021

Hi folks.

Found one interesting thing.
If you try to use detectDragGesture in pointerInput it wouldn't work on desktop cause of huge value of touchSlop configured in androidx.compose.ui.platform.DesktopViewConfiguration.

Every time i had try to drag something i run into awaitTouchSlopOrCancellation and then check if (distance >= touchSlop) allways fail cause distance (1~3) is allways less then value of touchSlop (its 18).

@olonho olonho added the input Touch, mouse, keyboard input related label Feb 3, 2021
@igordmn
Copy link
Collaborator

igordmn commented Feb 8, 2021

Thanks for the report!

Temporary solution - wrap top-level composable to this:

Window {
    WithoutTouchSlop {
        App()
    }
}

@Composable
private fun WithoutTouchSlop(content: @Composable () -> Unit) {
    fun ViewConfiguration.withoutTouchSlop() = object : ViewConfiguration {
        override val longPressTimeoutMillis get() =
            [email protected]

        override val doubleTapTimeoutMillis get() =
            [email protected]

        override val doubleTapMinTimeMillis get() =
            [email protected]

        override val touchSlop: Float get() = 0f
    }

    Providers(
        LocalViewConfiguration provides LocalViewConfiguration.current.withoutTouchSlop()
    ) {
        content()
    }
}

P.S. Touch slop should be available with touch screens on desktop, and on android there should be not touch slop if we use mouse.

So the temporary solution should be removed from the client code once the issue will be resolved.

@06000000-0000
Copy link

Hi

@LAP2
Copy link
Contributor Author

LAP2 commented Feb 12, 2021

Update, possibly we should use CompositionLocalProvider cause Provider is unavailable

@Jakobeha
Copy link

This seems to work now on my windows PC. Does anyone still have the issue?

@igordmn
Copy link
Collaborator

igordmn commented Oct 14, 2021

It should be fixed, yes

@igordmn igordmn closed this as completed Oct 14, 2021
MatkovIvan pushed a commit to MatkovIvan/compose-multiplatform that referenced this issue May 10, 2023
@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@JetBrains JetBrains locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working desktop input Touch, mouse, keyboard input related
Projects
None yet
Development

No branches or pull requests

7 participants