All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.io.nacular.doodle.theme.native.NativePointerPreprocessor.kt Maven / Gradle / Ivy

There is a newer version: 0.10.4
Show newest version
package io.nacular.doodle.theme.native

import io.nacular.doodle.core.View
import io.nacular.doodle.deviceinput.EventPreprocessor
import io.nacular.doodle.event.PointerEvent


internal typealias NativePointerHandler = (event: PointerEvent) -> Unit

internal class NativePointerPreprocessor: EventPreprocessor {
    private val handlers: MutableMap = mutableMapOf()

    override fun invoke(pointerEvent: PointerEvent) {
        handlers[pointerEvent.target]?.invoke(pointerEvent)
    }

    fun get(view: View) = handlers[view]
    fun set(view: View, handler: NativePointerHandler) {
        handlers[view] = handler
    }

    fun remove(view: View): NativePointerHandler? = handlers.remove(view)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy