https://kotlinlang.org logo
Title
l

lewik

07/20/2022, 12:57 PM
Is there a compose multiplatform channel? Where I can ask that type of questions? The question is how to handle mouse/finger moves for canvas? I'm rendering a map with canvas and want to handle drag, zoom etc actions. In the kotlin common code. I found detectTransformGestures but seems it's not working for desktop scroll I found other map libraries, but there is not enough features. And they have complex pointer handling. I feel there should be one builtin way for it (like detectTransformGestures).
4
d

darkmoon_uk

07/20/2022, 2:55 PM
+1 Want for a Compose Multiplatform channel. Might be redundant with the Desktop and Web channels, but we seem to lack a space to rally for Multiplatform as the ecosystem, and work through its unique configuration issues.
s

spierce7

07/20/2022, 3:47 PM
I feel like I just use the desktop or the compose channels for that currently.
m

Michael Paus

07/20/2022, 6:10 PM
@lewik Concerning your map question. I use detectTapGestures, detectTransformGestures and awaitPointerEventScope and that works on desktop as well as on Android. I can, e.g., zoom in/out with the two finger gesture on Android or via mouse-wheel on desktop. What exactly are your requirements?
g

Greg Steckman

07/21/2022, 2:53 AM
I've been using this for zoom and pan
suspend fun PointerInputScope.detectTransformGestures(
    panZoomLock: Boolean = false,
    onGesture: (centroid: Offset, pan: Offset, zoom: Float, rotation: Float) -> Unit
)
but it does not seem to work on Desktop or web-canvas with the scroll wheel. I had a look at the documentation for awaitPointerEventScope - it looks like if you use PointerEvent.calculateZoom() then you may not need to use detectTransformGestures at all? Does that behave as expected for desktop?