{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

PointerInputFilter

public abstract class 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.

Summary

Public constructors

Public methods

boolean

Intercept pointer input that children receive even if the pointer is out of bounds.

boolean

If false, then this PointerInputFilter will not allow siblings under it to respond to events.

final @NonNull IntSize

The layout size assigned to this PointerInputFilter.

abstract void

Invoked to notify the handler that no more calls to PointerInputFilter will be made, until at least new pointers exist.

abstract void
onPointerEvent(
    @NonNull PointerEvent pointerEvent,
    @NonNull PointerEventPass pass,
    @NonNull IntSize bounds
)

Invoked when pointers that previously hit this PointerInputFilter have changed.

Public constructors

PointerInputFilter

public PointerInputFilter()

Public methods

getInterceptOutOfBoundsChildEvents

public boolean getInterceptOutOfBoundsChildEvents()

Intercept pointer input that children receive even if the pointer is out of bounds.

If true, and a child has been moved out of this layout and receives an event, this will receive that event. If false, a child receiving pointer input outside of the bounds of this layout will not trigger any events in this.

getShareWithSiblings

public boolean getShareWithSiblings()

If false, then this PointerInputFilter will not allow siblings under it to respond to events. If true, this will have the first chance to respond and the next sibling under will then get a chance to respond as well. This trigger acts at the Layout level, so if any PointerInputFilters on a Layout has shareWithSiblings set to true then the Layout will share with siblings.

getSize

public final @NonNull IntSize getSize()

The layout size assigned to this PointerInputFilter.

onCancel

public abstract void onCancel()

Invoked to notify the handler that no more calls to PointerInputFilter will be made, until at least new pointers exist. This can occur for a few reasons:

  1. Android dispatches ACTION_CANCEL to Compose.

  2. This PointerInputFilter is no longer associated with a LayoutNode.

  3. This PointerInputFilter's associated LayoutNode is no longer in the composition tree.

onPointerEvent

public abstract void onPointerEvent(
    @NonNull PointerEvent pointerEvent,
    @NonNull PointerEventPass pass,
    @NonNull IntSize bounds
)

Invoked when pointers that previously hit this PointerInputFilter have changed. It is expected that any PointerInputChanges that are used during this event and should not be considered valid to be used in other filters should be marked as consumed by calling PointerInputChange.consume.

Parameters
@NonNull PointerEvent pointerEvent

The list of PointerInputChanges with positions relative to this PointerInputFilter.

@NonNull PointerEventPass pass

The PointerEventPass in which this function is being called.

@NonNull IntSize bounds

The width and height associated with this PointerInputFilter.