import { _decorator, Component, Label, Node } from 'cc';
import { tools } from '../../tools';
const { ccclass, property } = _decorator;

@ccclass('collect_event_item')
export class collect_event_item extends Component {
    @property(Node) lab_name:Node = null;
    @property(Node) btn_delete:Node = null;
    private m_id:number = 0;
    private m_delete_cb = null;
    protected start(): void {
        this.btn_delete.on(Node.EventType.TOUCH_END, ()=>{
            tools.show_dialog('确定删除?', ()=>{
                this.m_delete_cb && this.m_delete_cb(this.m_id)
            })
        })
    }
    public initView(id:number, is_widget:boolean=false){
        this.m_id = id
        let text = is_widget ? '控件' : '事件'
        this.lab_name.getComponent(Label).string = `${text}id:${id}`
        if(is_widget) {
            this.btn_delete.active = true
        } else {
            this.btn_delete.active = false
        }
    }
    public initDeleteCallback(delete_cb) {
        this.m_delete_cb = delete_cb
    }
}


