KuitoNativeEvent
The event an element listener receives, with the DOM's methods to stop its propagation or cancel its default action.
Verwendung
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>
);
}Typdeklaration
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[];
}Mitglieder 12
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
type | string | Ja | — |
bubbles | boolean | Ja | — |
cancelable | boolean | Ja | — |
isTrustedschreibgeschützt | boolean | Nein | — |
target | ElementHandle | Nein | — |
currentTarget | ElementHandle | Nein | — |
defaultPrevented | boolean | Nein | — |
eventPhase | number | Nein | — |
stopPropagation | () => void | Ja | — |
stopImmediatePropagation | () => void | Ja | — |
preventDefault | () => void | Ja | — |
composedPath | () => ElementHandle[] | Ja | — |
stopPropagation — Methodensignaturen
Signaturen
(): voidParameter
Keine Parameter.
Rückgabe
void
stopImmediatePropagation — Methodensignaturen
Signaturen
(): voidParameter
Keine Parameter.
Rückgabe
void
preventDefault — Methodensignaturen
Signaturen
(): voidParameter
Keine Parameter.
Rückgabe
void
composedPath — Methodensignaturen
Signaturen
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.