graphic-pixi/lib/plugins/KeyboardPlugin.d.ts

82 lines
2.9 KiB
TypeScript
Raw Permalink Normal View History

2023-12-12 17:31:07 +08:00
import { IGraphicApp } from '../app/JlGraphicApp';
export declare class GlobalKeyboardHelper {
appKeyboardPluginMap: JlGraphicAppKeyboardPlugin[];
constructor();
registerGAKPlugin(plugin: JlGraphicAppKeyboardPlugin): void;
removeGAKPlugin(plugin: JlGraphicAppKeyboardPlugin): void;
}
export declare class JlGraphicAppKeyboardPlugin {
app: IGraphicApp;
/**
* Map<key.code|key.key|key.keyCode, Map<KeyListener.identifier, KeyListener>>
*/
keyListenerMap: Map<number | string, Map<string, KeyListener>>;
keyListenerStackMap: Map<string, KeyListener[]>;
constructor(app: IGraphicApp);
private getOrInit;
private getOrInitStack;
/**
*
* @param keyListener
*/
addKeyListener(keyListener: KeyListener): void;
/**
*
* @param keyListener
*/
removeKeyListener(keyListener: KeyListener): void;
getKeyListenerBy(key: string | number): Map<string, KeyListener> | undefined;
getKeyListener(e: KeyboardEvent): Map<string, KeyListener> | undefined;
isKeyListened(key: string | number): boolean;
/**
*
*/
getAllListenedKeys(): string[];
}
type KeyboardKeyHandler = (e: KeyboardEvent, app: IGraphicApp) => void;
export declare enum CombinationKey {
Ctrl = "Ctrl",
Alt = "Alt",
Shift = "Shift"
}
export interface KeyListenerOptions {
value: string | number;
combinations?: CombinationKey[];
global?: boolean;
onPress?: KeyboardKeyHandler;
pressTriggerAsOriginalEvent?: boolean;
onRelease?: KeyboardKeyHandler;
}
export interface ICompleteKeyListenerOptions {
value: string | number;
combinations: CombinationKey[];
global: boolean;
onPress?: KeyboardKeyHandler;
pressTriggerAsOriginalEvent: boolean;
onRelease?: KeyboardKeyHandler;
}
export declare class KeyListener {
readonly options: ICompleteKeyListenerOptions;
private isPress;
constructor(options: KeyListenerOptions);
static create(options: KeyListenerOptions): KeyListener;
get value(): string | number;
get combinations(): string[];
get identifier(): string;
get global(): boolean | undefined;
get onPress(): KeyboardKeyHandler | undefined;
set onPress(v: KeyboardKeyHandler | undefined);
get onRelease(): KeyboardKeyHandler | undefined;
set onRelease(v: KeyboardKeyHandler | undefined);
get pressTriggerEveryTime(): boolean;
set pressTriggerEveryTime(v: boolean);
press(e: KeyboardEvent, app: IGraphicApp): void;
/**
*
*/
checkCombinations(e: KeyboardEvent): boolean;
release(e: KeyboardEvent, app: IGraphicApp): void;
onRemove(): void;
}
export {};