Build apps faster with our new App builder! Check it out →

pointerInteropFilter

Android

Modifier in Compose Ui

A special PointerInputModifier that provides access to the underlying [MotionEvent]s originally dispatched to Compose. Prefer [pointerInput] and use this only for interoperation with existing code that consumes [MotionEvent]s.

While the main intent of this Modifier is to allow arbitrary code to access the original [MotionEvent] dispatched to Compose, for completeness, analogs are provided to allow arbitrary code to interact with the system as if it were an Android View.

This includes 2 APIs,

  1. [onTouchEvent] has a Boolean return type which is akin to the return type of [View.onTouchEvent]. If the provided [onTouchEvent] returns true, it will continue to receive the event stream (unless the event stream has been intercepted) and if it returns false, it will not.
  2. [requestDisallowInterceptTouchEvent] is a lambda that you can optionally provide so that you can later call it (yes, in this case, you call the lambda that you provided) which is akin to calling [ViewParent.requestDisallowInterceptTouchEvent]. When this is called, any associated ancestors in the tree that abide by the contract will act accordingly and will not intercept the even stream.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.ui:ui:1.8.0-alpha04")
}

Overloads


fun Modifier.pointerInteropFilter(
    requestDisallowInterceptTouchEvent: (RequestDisallowInterceptTouchEvent)? = null,
    onTouchEvent: (MotionEvent) -> Boolean
): Modifier
by @alexstyl