lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
39 lines • 1.68 kB
JavaScript
import { VirtualKeyboard } from '../widgets/concrete-widgets.js';
import { DOMRoot } from './DOMRoot.js';
import { Background } from '../widgets/Background.js';
import { defaultVirtualKeyboardTemplate } from './VirtualKeyboardTemplate.js';
/**
* A {@link DOMRoot} with similar functionality to {@link VirtualKeyboardRoot}.
* In this version {@link VirtualKeyboardRoot#updateVisibility} doesn't exist.
* Instead, just call {@link DOMVirtualKeyboardRoot#update} like in DOMRoot.
*
* @category Core
*/
export class DOMVirtualKeyboardRoot extends DOMRoot {
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 DOMRoot.
*
* If root is disabled, {@link DOMRoot#domElem}'s display style is set to
* 'none', hiding it.
*
* Calls {@link Root#preLayoutUpdate}, {@link Root#resolveLayout},
* {@link Root#postLayoutUpdate} and {@link Root#paint}.
*
* Also updates the visibility of this root; if the keyboard driver has no
* focused root, then the root is disabled, else, it is enabled.
*/
update() {
// Update visibility of root by enabling/disabling it
this.enabled = this.keyboardDriver.needsInput;
// Update normally
super.update();
}
}
//# sourceMappingURL=DOMVirtualKeyboardRoot.js.map