Compose Modifier

oneHandedGesture

Registers a gesture handler.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free

oneHandedGesture

Android
@Composable
public fun Modifier.oneHandedGesture(
    action: GestureAction,
    key: String? = null,
    priority: GesturePriority = GesturePriority.Unspecified,
    enabledInAmbient: Boolean = false,
    interactionSource: MutableInteractionSource? = null,
    onShowIndicator: () -> Unit = {},
    onGesture: suspend () -> Unit,
): Modifier

Registers a gesture handler.

When a gesture is successfully triggered, the system automatically performs haptic feedback to acknowledge the interaction; developers do not need to trigger haptics manually within onGesture.

Example of adding one-handed gesture handler to a androidx.wear.compose.material3.Button:

Example of adding one-handed gesture handler to a androidx.wear.compose.foundation.lazy.TransformingLazyColumn:

Example of adding one-handed gesture handler to a androidx.wear.compose.foundation.pager.HorizontalPager:

Example of adding one-handed gesture handler to a androidx.wear.compose.foundation.pager.VerticalPager:

Parameters

action The gesture action to handle.
key A unique identifier for this gesture instance. This ID allows the system to track user interactions - for example, to mute gesture indicators that have been frequently shown or successfully performed, in accordance with user preferences. If the same key is reused across multiple gestures, they will share a common interaction history (such as frequency-based gesture indicator display logic). Note that this only affects the presentation of the UI; the underlying logic and handling remain independent for each instance. If key is null or empty, a unique key will be automatically generated based on the composition position of this gesture.
priority The priority value; higher values take precedence if multiple handlers are registered for the same action. It is not recommended to register multiple gestures for the same action and priority (but if that is the case, all of them will be actioned).
enabledInAmbient Whether the gesture should remain active in ambient mode.
interactionSource MutableInteractionSource that will be used to dispatch androidx.compose.foundation.interaction.Interactions for this gesture. This can be used to visualize the gesture state (e.g., showing a ripple or custom pressed state) when the one-handed gesture is being interacted with.
onShowIndicator Callback invoked when the system determines a gesture indicator should be displayed for this component. This occurs when the component is visible and holds the highest priority for the current gesture. Only GestureAction.Primary gesture indicator callbacks will be called.
onGesture The callback invoked when the gesture is triggered.