androidx.compose.ui.input.pointer

Interfaces

CustomEvent

The base type for all custom events.

CustomEventDispatcher

Defines the interface that is used to dispatch CustomEvents to pointer input nodes across the compose tree.

PointerInputModifier

A Modifier.Element that can interact with pointer input.

Classes

ConsumedData

Describes what aspects of, and how much of, a change has been consumed.

PointerEvent

Describes a pointer input change event that has occurred at a particular point in time.

PointerId

An ID for a given pointer.

PointerInputChange

Describes a change that has occurred for a particular pointer, as well as how much of the change has been consumed (meaning, used by a node in the UI).

PointerInputData

Data associated with a pointer.

PointerInputEvent

PointerInputEventData

Data that describes a particular pointer

PointerInputFilter

A PointerInputFilter represents a single entity that receives PointerInputChanges), interprets them, and consumes the aspects of the changes that it is react to such that other PointerInputFilters don't also react to them.

RequestDisallowInterceptTouchEvent

Function that can be passed to pointerInteropFilter and then later invoked which provides an analog to ViewParent.requestDisallowInterceptTouchEvent.

Type-aliases

PointerInputHandler

A function used to react to and modify PointerInputChanges.

Enums

PointerEventPass

The enumeration of passes where PointerInputChange traverses up and down the UI tree.

Extension functions summary

For PointerInputChange
Boolean

True if any aspect of this PointerInputChange has been consumed.

Boolean

True if any of this PointerInputChange's movement has been consumed.

Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen and that change has not been consumed.

Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen, whether or not that change has been consumed.

Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen and that change has not been consumed.

Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen, whether or not that change has been consumed.

PointerInputChange

Consumes all changes associated with the PointerInputChange

PointerInputChange

Consume the up or down change of this PointerInputChange if there is an up or down change to consume.

PointerInputChange

Consumes some portion of the position change of this PointerInputChange.

Offset

The distance that the pointer has moved on the screen minus any distance that has been consumed.

Offset

The distance that the pointer has moved on the screen, ignoring any distance that may have been consumed.

Boolean

True if this PointerInputChange represents a pointer moving on the screen and some of that movement has not been consumed.

Boolean

True if this PointerInputChange represents a pointer moving on the screen ignoring how much of that movement may have been consumed.

For Modifier
Modifier
Modifier.pointerInteropFilter(requestDisallowInterceptTouchEvent: RequestDisallowInterceptTouchEvent? = null, onTouchEvent: (MotionEvent) -> Boolean)

A special PointerInputModifier that provides access to the underlying MotionEvents originally dispatched to Compose.

Extension functions

anyChangeConsumed

fun PointerInputChange.anyChangeConsumed(): Boolean

True if any aspect of this PointerInputChange has been consumed.

anyPositionChangeConsumed

fun PointerInputChange.anyPositionChangeConsumed(): Boolean

True if any of this PointerInputChange's movement has been consumed.

changedToDown

fun PointerInputChange.changedToDown(): Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen and that change has not been consumed.

changedToDownIgnoreConsumed

fun PointerInputChange.changedToDownIgnoreConsumed(): Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen, whether or not that change has been consumed.

changedToUp

fun PointerInputChange.changedToUp(): Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen and that change has not been consumed.

changedToUpIgnoreConsumed

fun PointerInputChange.changedToUpIgnoreConsumed(): Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen, whether or not that change has been consumed.

consumeAllChanges

fun PointerInputChange.consumeAllChanges(): PointerInputChange

Consumes all changes associated with the PointerInputChange

Note: This function creates a modified copy of this PointerInputChange

consumeDownChange

fun PointerInputChange.consumeDownChange(): PointerInputChange

Consume the up or down change of this PointerInputChange if there is an up or down change to consume.

Note: This function creates a modified copy of this PointerInputChange.

consumePositionChange

fun PointerInputChange.consumePositionChange(
    consumedDx: Float,
    consumedDy: Float
): PointerInputChange

Consumes some portion of the position change of this PointerInputChange.

Note: This function creates a modified copy of this PointerInputChange

Parameters
consumedDx: Float The amount of position change on the x axis to consume.
consumedDy: Float The amount of position change on the y axis to consume.

pointerInteropFilter

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

A special PointerInputModifier that provides access to the underlying MotionEvents originally dispatched to Compose.

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.

positionChange

fun PointerInputChange.positionChange(): Offset

The distance that the pointer has moved on the screen minus any distance that has been consumed.

positionChangeIgnoreConsumed

fun PointerInputChange.positionChangeIgnoreConsumed(): Offset

The distance that the pointer has moved on the screen, ignoring any distance that may have been consumed.

positionChanged

fun PointerInputChange.positionChanged(): Boolean

True if this PointerInputChange represents a pointer moving on the screen and some of that movement has not been consumed.

positionChangedIgnoreConsumed

fun PointerInputChange.positionChangedIgnoreConsumed(): Boolean

True if this PointerInputChange represents a pointer moving on the screen ignoring how much of that movement may have been consumed.