Hey all, can anybody help me, how to add a Gesture...
# kotlin-native
a
Hey all, can anybody help me, how to add a GestureRecognizer to a UIView from Kotlin? I'm trying to achieve the ability to start a function (passed as a lambda), when a View is pressed. Here is what I tried: (ViewContainer is a typealias for UIView, I want to use this in the common presenter of an Android/iOS-Multiplatform project)
Copy code
actual fun ViewContainer.setOnCLickListener(block: () -> Unit) {
    val funRef = StableRef.create(InvokeClickListener(block))

    this.addGestureRecognizer(UITapGestureRecognizer(this, funRef.asCPointer()))
}

class InvokeClickListener(private val block: () -> Unit) : () -> Unit {
    override operator fun invoke() {
        block()
    }
}
I already managed to set the visibility of Views in the common code. If interested I can post code snippets in the multiplatform channel. But this case is harder, because UITapGestureRecognizer wants a selector/COpaquePointer and I can't find a solution.
s