UNPKG

lazy-widgets

Version:

Typescript retained mode GUI for the HTML canvas API

31 lines 1.44 kB
import { VirtualKeyboard } from '../widgets/VirtualKeyboard/VirtualKeyboard.js'; import { defaultVirtualKeyboardTemplate } from './VirtualKeyboardTemplate.js'; import { Root } from './Root.js'; import { Background } from '../widgets/Background.js'; /** * A {@link Root} containing a single {@link VirtualKeyboard} widget. * Automatically disables itself if not needed, but * {@link VirtualKeyboardRoot#updateVisibility} must be called every frame for * this behaviour to occur. * * @category Core */ export class VirtualKeyboardRoot extends Root { constructor(keyboardDriver, properties) { var _a; super(new Background(new VirtualKeyboard(keyboardDriver, (_a = properties === null || properties === void 0 ? void 0 : properties.keyboardTemplate) !== null && _a !== void 0 ? _a : defaultVirtualKeyboardTemplate), { containerPadding: { left: 8, right: 8, top: 8, bottom: 8 }, }), properties); this.keyboardDriver = keyboardDriver; } /** * Update the visibility of this root; if the keyboard driver has no focused * root, then the root is disabled, else, it is enabled. Call this method * on every frame to automatically enable/disable the root if needed */ updateVisibility() { // Update visibility of root by enabling/disabling it this.enabled = this.keyboardDriver.needsInput; } } //# sourceMappingURL=VirtualKeyboardRoot.js.map