Skip to content

1681-engine / ui / UiPointerGate

Variable: UiPointerGate ​

ts
const UiPointerGate: object;

Defined in: src/ui/UiPointerGate.ts:17

Keeps a press on a canvas widget from also counting as a press in the world.

Pixi's event system listens on the canvas in the capture phase, so it hit-tests the widgets and runs their pointerdown handlers before Pointer's own listener on the same canvas sees the event. A widget marks the native event (consume), and the gate, chained into Pointer.ignorePress, tells Pointer to leave that press out. A game's own ignorePress keeps working: the gate asks it too.

Type Declaration ​

consume() ​

ts
consume(e): void;

Marks a native event (a federated event's nativeEvent) as taken by the UI.

Parameters ​

ParameterType
eobject | null | undefined

Returns ​

void

install() ​

ts
install(): () => void;

Chains the gate into Pointer.ignorePress; counted, so two UI roots install it once. Returns the uninstall.

Returns ​

() => void

wasConsumed() ​

ts
wasConsumed(e): boolean;

Whether the UI took this native event (a game's own canvas listener may ask too).

Parameters ​

ParameterType
eobject | null | undefined

Returns ​

boolean

Released under the MIT License.