KuitoNativeEvent
The event an element listener receives, with the DOM's methods to stop its propagation or cancel its default action.
Usage
Handle event propagation and cancellation.
// Handle event propagation and cancellation.
import { Box, Button, onMount, ref, signal, type KuitoNativeEvent } from 'kuito';
const saving = signal(false);
function Form(props: { onSave: () => void }) {
const form = ref();
// In the capture phase the form sees a press before the button inside it does,
// and stops it while a save is running.
const guard = (event: KuitoNativeEvent) => {
if (saving.value) event.stopPropagation();
};
onMount(() => form.current?.addEventListener('press', guard, { capture: true }));
return (
<Box ref={form}>
<Button onPress={props.onSave}>Save</Button>
</Box>
);
}Type declaration
export interface KuitoNativeEvent {
type: string;
bubbles: boolean;
cancelable: boolean;
readonly isTrusted?: boolean;
target?: ElementHandle;
currentTarget?: ElementHandle | null;
defaultPrevented?: boolean;
eventPhase?: number;
stopPropagation(): void;
stopImmediatePropagation(): void;
preventDefault(): void;
composedPath(): ElementHandle[];
}Members 12
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | — |
bubbles | boolean | Yes | — |
cancelable | boolean | Yes | — |
isTrustedreadonly | boolean | No | — |
target | ElementHandle | No | — |
currentTarget | ElementHandle | No | — |
defaultPrevented | boolean | No | — |
eventPhase | number | No | — |
stopPropagation | () => void | Yes | — |
stopImmediatePropagation | () => void | Yes | — |
preventDefault | () => void | Yes | — |
composedPath | () => ElementHandle[] | Yes | — |
stopPropagation — method signatures
Signatures
(): voidParameters
No parameters.
Returns
void
stopImmediatePropagation — method signatures
Signatures
(): voidParameters
No parameters.
Returns
void
preventDefault — method signatures
Signatures
(): voidParameters
No parameters.
Returns
void
composedPath — method signatures
Signatures
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.