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

ForEachGestureKt

public final class ForEachGestureKt


Summary

Public methods

static final void

Repeatedly calls block to handle gestures.

static final void
forEachGesture(
    @NonNull PointerInputScope receiver,
    @ExtensionFunctionType @NonNull SuspendFunction1<@NonNull PointerInputScopeUnit> block
)

This method is deprecated. Use awaitEachGesture instead. forEachGesture() can drop events between gestures.

Public methods

awaitEachGesture

public static final void awaitEachGesture(
    @NonNull PointerInputScope receiver,
    @ExtensionFunctionType @NonNull SuspendFunction1<@NonNull AwaitPointerEventScopeUnit> block
)

Repeatedly calls block to handle gestures. If there is a CancellationException, it will wait until all pointers are raised before another gesture is detected, or it exits if isActive is false.

block is run within PointerInputScope.awaitPointerEventScope and will loop entirely within the AwaitPointerEventScope so events will not be lost between gestures.

forEachGesture

public static final void forEachGesture(
    @NonNull PointerInputScope receiver,
    @ExtensionFunctionType @NonNull SuspendFunction1<@NonNull PointerInputScopeUnit> block
)

Repeatedly calls block to handle gestures. If there is a CancellationException, it will wait until all pointers are raised before another gesture is detected, or it exits if isActive is false.

awaitEachGesture does the same thing without the possibility of missing events between gestures, but also lacks the ability to call arbitrary suspending functions within block.