lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
59 lines (58 loc) • 2.22 kB
TypeScript
import { VirtualKey } from '../widgets/VirtualKeyboard/VirtualKey.js';
import type { WidgetProperties } from '../widgets/Widget.js';
import type { KeyContext } from './KeyContext.js';
/**
* A template for a single virtual keyboard key. A function that, when called
* given a {@link KeyContext} and theme override, returns a {@link VirtualKey}
* which can be used as a virtual keyboard key widget.
*
* Example:
* ```typescript
* const template: VirtualKeyTemplate = (keyContext, properties) => new BackspaceKey(keyContext, properties);
* ```
*
* @category Core
*/
export type VirtualKeyTemplate = (keyContext: KeyContext, properties?: Readonly<WidgetProperties>) => VirtualKey;
/**
* A template for multiple {@link GlyphVirtualKey} virtual keyboard keys. A
* 2-tuple of strings, where each string has the same length. Each character of
* the string represents a glyph to add to a keyboard row. The first string of
* the tuple has the regular glyphs, while the second string string of the tuple
* has the alternative glyphs.
*
* Example:
* ```typescript
* const template: GlyphVirtualKeysTemplate = ['qwertyuiop', 'QWERTYUIOP'];
* ```
*
* @category Core
*/
export type GlyphVirtualKeysTemplate = [string, string];
/**
* A template for a single row of virtual keyboard keys. An array of
* {@link GlyphVirtualKeysTemplate} and {@link VirtualKeyTemplate}.
*
* Example:
* ```typescript
* const backspaceTemplate: VirtualKeyTemplate = (keyContext, themeProperties) => new BackspaceKey(keyContext, themeProperties);
* const rowTemplate: VirtualKeyRowTemplate = [['`1234567890-=', '~!@#$%^&*()_+'], backspaceTemplate];
* ```
*
* @category Core
*/
export type VirtualKeyRowTemplate = Array<GlyphVirtualKeysTemplate | VirtualKeyTemplate>;
/**
* A template for the keys in a {@link VirtualKeyboard}. Each member of the
* array contains the template for a row of keys, from top to bottom.
*
* @category Core
*/
export type VirtualKeyboardTemplate = Array<VirtualKeyRowTemplate>;
/**
* The default template for the keys in a {@link VirtualKeyboard}; A QWERTY
* keyboard with US layout.
*
* @category Core
*/
export declare const defaultVirtualKeyboardTemplate: VirtualKeyboardTemplate;