New Compose Multiplatform components arrived on Composables UICheck it out →

Modifier in Compose Ui

motionEventSpy

Android

Calls [watcher] with each [MotionEvent] that the layout area or any child [pointerInput] receives. The [MotionEvent] may or may not have been transformed to the local coordinate system. The Compose View will be considered as handling the [MotionEvent] in the area that the [motionEventSpy] is active.

This method can only be used to observe [MotionEvent]s and can not be used to capture an event stream.

[watcher] is called during the [PointerEventPass.Initial] pass.

Developers should use [pointerInput] to handle pointer input processing within Compose. [motionEventSpy] is only useful as part of Android View interoperability.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.ui:ui:1.7.0-beta04")
}

Overloads

@ExperimentalComposeUiApi
fun Modifier.motionEventSpy(watcher: (motionEvent: MotionEvent) -> Unit)