PressClaims

Press claims: the pointer downs and keys presses started from, and whether a press claimed one, so a press that doesn't propagate (Recognizer.press's propagate: false) keeps its ancestors' presses from starting on the same down. A key a press inside started from, and didn't claim, presses its pressable ancestors too, as a pointer's down does. Recognizer's presses mark and read them; a recognizer of your own that presses does the same.

By default every runtime shares one, as Motion's are shared; a runtime can provide its own, as the test Environment does. It's synchronous, so a press reads it as it decides.

import * as PressClaims from "@wardic/core/PressClaims"

const claims = yield* PressClaims.PressClaims
claims.mark(down, button, true) // the button's press claims the down
claims.markOf(down, card) // "claimed": the card's press doesn't start

Interfaces

Markable

An event a press can start from, a pointer's down or a key's.

Properties

raw?
readonly raw?: unknown;

The platform's own event, which keys its mark when it's an object: each target an event passes through gets its own copy, and the copies share it. Without one, the event itself keys it.


Shape

A set of Press claims: what PressClaims gives.

Properties

mark
readonly mark: (event, target, claimed) => void;

Note that a press on target started from event: claimed when that press doesn't propagate. A claim stays claimed, and stays its target's.

Parameters
event

Markable

target

unknown

claimed

boolean

Returns

void

markOf
readonly markOf: (event, target) => Mark;

What the presses so far made of event, as target sees it: its own claim reads as "pressed".

Parameters
event

Markable

target

unknown

Returns

Mark

Type Aliases

Mark

type Mark = "none" | "pressed" | "claimed";

What the presses inside a target made of an event: "none", no press started from it; "pressed", one did and let it propagate; "claimed", one claimed it.

Variables

PressClaims

const PressClaims: Context.Reference<Shape>;

The runtime's Press claims: one shared by every runtime unless a runtime provides its own.

Functions

make()

function make(): Shape;

Fresh Press claims, with nothing marked: for a runtime that provides its own. Each mark goes with its event.

Returns

Shape