Compose Modifier

onIndirectPointerGesture

A Modifier that detects high-level click and horizontal swipe gestures from an IndirectPointerEvent source.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free

onIndirectPointerGesture

Android
public fun Modifier.onIndirectPointerGesture(
    enabled: Boolean = true,
    onSwipeForward: (() -> Unit)? = null,
    onSwipeBackward: (() -> Unit)? = null,
    onClick: (() -> Unit)? = null,
): Modifier

A Modifier that detects high-level click and horizontal swipe gestures from an IndirectPointerEvent source. The component (or one of its descendants) using this modifier must be focused to intercept events.

This modifier allows optionality for swipe gesture callbacks. If a specific swipe gesture callback is null, the corresponding swipe events will not be consumed by this modifier. For example:

  • When nesting onIndirectPointerGesture modifiers, if the inner modifier provides an onSwipeBackward callback but leaves onSwipeForward as null, the outer modifier can still detect and handle the forward swipe, and vice versa.

Note that the initial down event is always consumed by this modifier (if not already consumed) as long as at least one callback (onClick, onSwipeForward, or onSwipeBackward) is provided.

Parameters

enabled Controls whether gesture detection is active. When false, this modifier has no effect and no callbacks will be invoked.
onSwipeForward Invoked when a successful forward swipe is detected.
onSwipeBackward Invoked when a successful backward swipe is detected.
onClick Invoked when a successful click is detected.