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

Mouse drag on Canvas is delayed #622

Closed
mipastgt opened this issue Apr 29, 2021 · 4 comments
Closed

Mouse drag on Canvas is delayed #622

mipastgt opened this issue Apr 29, 2021 · 4 comments
Assignees
Labels
duplicate This issue or pull request already exists input Touch, mouse, keyboard input related

Comments

@mipastgt
Copy link

I have a Canvas where I have attached the following code to the modifier in order to catch mouse drag events.

.pointerInput(Unit) {
    detectDragGestures { change, dragAmount ->
        change.consumeAllChanges()
        println("dragAmount: $dragAmount")
    }
}

This works well in general but I observe one strange behavior. In order to get the first event I have to drag the mouse almost one centimeter (on a large screen) away from the initial point where the left mouse button was pressed. After that the events are comming in as expected. This effect is critical because it makes any detailed mouse based editing impossible.

I am on macOS 10.15.7 with a large Retina screen and I am using the compose plugin 0.4.0-build185.

@igordmn
Copy link
Collaborator

igordmn commented Apr 30, 2021

Thanks!

We plan to fix this soon.
You can track the issue here

Until then you can use a workaround

Or use this instead of detectDrageGestures:

.pointerInput(Unit) {
    forEachGesture {
        awaitPointerEventScope {
            val down = awaitFirstDown()
            drag(down.id) { change ->
                change.consumePositionChange()
                ...
            }
        }
    }
}

@igordmn igordmn closed this as completed Apr 30, 2021
@igordmn igordmn self-assigned this Apr 30, 2021
@igordmn igordmn added duplicate This issue or pull request already exists input Touch, mouse, keyboard input related labels Apr 30, 2021
@mipastgt
Copy link
Author

Just incorporated your second proposal into my code and it works great. Thanks a lot. The only drawback is that I have to compute the dragAmount myself now :-) (Which is very easy thanks to Kotlin val dragAmount = change.position - change.previousPosition)

@mipastgt
Copy link
Author

I still have this issue and just had to use the above workarround again.
I am now on macOS 12.6.3, Kotlin 1.8.10 and Compose desktop 1.3.1.

@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
duplicate This issue or pull request already exists input Touch, mouse, keyboard input related
Projects
None yet
Development

No branches or pull requests

3 participants