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> */ keyListenerMap: Map>; keyListenerStackMap: Map; constructor(app: IGraphicApp); private getOrInit; private getOrInitStack; /** * 注册按键监听,若有旧的,旧的入栈 * @param keyListener */ addKeyListener(keyListener: KeyListener): void; /** * 移除按键监听,若是当前注册的监听,尝试从栈中取出作为按键监听器,若是旧的,则同时移除栈中的监听 * @param keyListener */ removeKeyListener(keyListener: KeyListener): void; getKeyListenerBy(key: string | number): Map | undefined; getKeyListener(e: KeyboardEvent): Map | 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 {};