Hi guys, there is still no way to pinch-zoom on de...
# compose-desktop
a
Hi guys, there is still no way to pinch-zoom on desktop right? Is there any workaround to be able to do it? It's the one thing I really miss with Compose desktop.
but since compose-desktop uses Swing and Swing doesn't support touch gestures, I'm not sure how this would be resolved
a
Thanks @ephemient. Tbh, I don't understand how this is tagged as "enhancement" when a lot of people use their laptop without a mouse... There is a hacky way of getting gestures with Swing apparently: https://stackoverflow.com/questions/48535595/what-replaces-gestureutilities-in-java-9 I wonder perhaps the JBR JDK has some fixes for gesture support, e.g. in IntelliJ you can pan to zoom. @Igor Demin
And it seems Fleet has the support for pinch zoom https://youtrack.jetbrains.com/issue/FL-10296/Touchpad-gestures-support
a
I’m a month late, but here’s something I have hacked together for my project: https://gist.github.com/AlexKGwyn/bd404385ef659a94e18d35599bf7798e You need access to a SwingWindow though, which I setup with a CompositionLocal in the root Window{} composable.
Copy code
Window(){
    ...
    CompositionLocalProvider(SwingWindow provides window) {
        ....
    }
}
I think there might be some other steps around accessing the apple API and also iirc there was an issue in the default JDK at one point that caused errors to be thrown for every zoom event. Let me know if this helps!
a
@Alex Gwyn Cool, thanks! Your code is for OSX, right? I haven't tried other platforms, do you know if pinch zoom works on them? It seems the GestureUtilities need a special compiler flag to be accessible at runtime? "--add-opens java.desktop/com.apple.eawt.event=ALL-UNNAMED"
a
Ya this is specifically for OSX, I haven’t looked into windows or linux yet
Ahh ya, I also have this added in my build.gradle
Copy code
tasks.withType<JavaCompile> {
    options.compilerArgs.addAll(
        listOf(
            "-XDignore.symbol.file",
            "--add-exports",
            "java.desktop/com.apple.eawt.event=ALL-UNNAMED"
        )
    )
}
Eventually, I’ll get around to looking in on other platforms and making this a library, but hope this helps for now!
258 Views