import {GamePool} from "../PrefabControl/GamePool";

export class ComponentEventData
{
    static ResDicValue:string = "ComponentEventData";

    /************************ */
    private logger: Text;
    private keyDownList: Array<boolean>;


    target:any;
    type:string;
    thisObject:any;
    listener:Function;

    private listenKeyboard(): void {
        this.keyDownList = [];

        //添加键盘按下事件,一直按着某按键则会不断触发
        Laya.stage.on(Laya.Event.KEY_DOWN, this, this.onKeyDown);
        //添加键盘抬起事件
        Laya.stage.on(Laya.Event.KEY_UP, this, this.onKeyUp);
    }

    /**键盘按下处理*/
    private onKeyDown(e: Event): void {
        var keyCode: number = e["keyCode"];
        this.keyDownList[keyCode] = true;
    }

    
    public clear():void
    {
        this.target = null;
        this.type=null;
        this.thisObject=null;
        this.listener=null;
        GamePool.RemoveItem( ComponentEventData.ResDicValue,this );
    }

    /**键盘抬起处理*/
    private onKeyUp(e: Event): void {
        delete this.keyDownList[e["keyCode"]];
    }

}