Input layers ​
inputLayers records which keyboard events belong to the UI. While a layer is open, every keydown and keypress is claimed in a window capture listener. keyup is never claimed.
ts
interface InputLayerOptions {
dismiss?: () => boolean;
}
class InputLayers {
constructor(options?: { target?: () => EventTarget });
readonly open: boolean;
push(options?: InputLayerOptions): () => void;
dismissAll(): boolean;
blocks(event: Event): boolean;
onEngage(listener: () => void): () => void;
}
const inputLayers: InputLayers;push()opens a layer and returns an idempotent release.blocks(event)istruefor a claimed event, even when a listener closed the last layer during its dispatch, as Escape does.onEngagelisteners run when the first layer opens.dismissAll()callsdismisson every layer, newest first, and returnstrueonly when all closed. A layer withoutdismissrefuses and stays open. Onfalse, do not open over it.
Holders ​
jolly-dialog, while open. Dismissing it cancels it, unlessdismissibleisfalse.- Every
PopoverControllerpopover, unlessclaimsInputisfalse. Dismissing hides it. - Hover flyouts such as
jolly-tool-buttonhold none.
Keyboard guard ​
The shape matches the KeyboardGuard of @jolly-pixel/controls. Wire them once, and the keyboard ignores keys pressed while a dialog or popover is open:
ts
import { inputLayers } from "@jolly-pixel/ui";
const dispose = input.keyboard.addGuard(inputLayers);