https://kotlinlang.org logo
Title
m

Michael Paus

05/22/2022, 10:19 AM
I tried to experiment with mouse scroll events following this tutorial from JetBrains: https://github.com/JetBrains/compose-jb/blob/master/tutorials/Mouse_Events/README.md#mouse-events But when I build the project all I get is this:
e: …/CmpMapPane.kt: (132, 55): This API is experimental and is likely to change in the future.
How can I get rid of that and get my code compiled. I’ve added
@OptIn(ExperimentalFoundationApi::class)
to the composable function on which I use the pointerInput modifier but IntelliJ is only telling me
The opt-in annotation is redundant: no matching experimental API is used.
s

spierce7

05/22/2022, 9:40 PM
In your build.gradle.kts for the project add:
tasks.withType<KotlinCompile> {
        kotlinOptions {
            freeCompilerArgs = freeCompilerArgs + arrayOf(
                "-Xopt-in=<whatever the package is here>.ExperimentalFoundationApi"
            )
        }
    }
:thank-you: 1
m

Michael Paus

05/23/2022, 2:54 PM
According to: https://kotlinlang.org/docs/opt-in-requirements.html#require-opt-in-for-api I fixed the problem by adding
all {
    languageSettings.optIn("androidx.compose.ui.ExperimentalComposeUiApi")
}
to the sourceSets. The real problem was that I picked the wrong optIn because they are using different ones in the examples. The code compiles and runs now but mouse wheel scrolling still does not seem to work. The reported value is always zero.
s

spierce7

05/23/2022, 3:44 PM
👍