import { _decorator, Color, Component, Label, Node, Sprite } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('show_select_more_scene_page_item')
export class show_select_more_scene_page_item extends Component {
    @property(Node) lab_name: Node = null;
    private m_is_select: boolean = false;
    private m_index:number = null;
    private m_callback: Function = null;
    start() {
        this.node.on(Node.EventType.TOUCH_END, ()=> {
            if(this.m_callback != null) {
                this.m_callback(this)
            }
        },this)
    }

    initView(name:string, index:number, callback: Function) {
        this.m_index = index
        this.lab_name.getComponent(Label).string = name
        this.m_callback = callback
    }

    getIndex():number {
        return this.m_index
    }

    setIsSelect(isSelect:boolean){
        this.m_is_select = isSelect
    }

    getSelect():boolean {
        return this.m_is_select
    }

    updatSelectStatus(){
        if(this.m_is_select){
            this.lab_name.getComponent(Label).color = Color.RED
        }else{
            this.lab_name.getComponent(Label).color = Color.BLACK
        }
    }
}

