Usage

Read a long press location and duration.

This type is used by longPress

tsx
// Read a long press location and duration.
import { Box, longPress, signal, type LongPressEvent } from 'kuito';

const menuAt = signal<{ x: number; y: number } | null>(null);

// Opens a menu where the finger rests, once it has been held.
const open = (event: LongPressEvent) => {
  menuAt.value = { x: event.absoluteX, y: event.absoluteY };
};

<Box gestures={[longPress({ after: 400, onStart: open })]} height={64} />;

Type declaration

ts
export interface LongPressOptions extends Common, Callbacks<LongPressEvent, LongPressEvent> {
  /** Milliseconds held before it activates; 500 by default. */
  after?: number;
  maxDistance?: number;
}

Members 7

NameTypeRequiredDescription
afternumberNoMilliseconds held before it activates; 500 by default.
maxDistancenumberNo—
disabledbooleanNoIgnores touches, like a disabled Pressable.
hitAreaHitAreaNoInsets of the area that takes touches: one for every edge, or by edge.
onStart(event: LongPressEvent) => voidNoIt activated.
onChange(event: LongPressEvent) => voidNoIt moved, with the change since the last move.
onEnd(event: LongPressEvent, success: boolean) => voidNoIt ended after activating: success is false when it was cancelled.
onStart — method signatures

Signatures

ts
(event: LongPressEvent): void

Parameters

NameTypeRequiredDescription
eventLongPressEventYes—

Returns

void

onChange — method signatures

Signatures

ts
(event: LongPressEvent): void

Parameters

NameTypeRequiredDescription
eventLongPressEventYes—

Returns

void

onEnd — method signatures

Signatures

ts
(event: LongPressEvent, success: boolean): void

Parameters

NameTypeRequiredDescription
eventLongPressEventYes—
successbooleanYes—

Returns

void

Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.