import { _decorator, Component, EditBox, Node } from 'cc';
import { interact_input_data } from '../../../data/data';
import { receive_widget_item } from './receive_widget_item';
import { config } from '../../config';
import { ClientEvent } from '../../clientEvent';
const { ccclass, property } = _decorator;

@ccclass('widget_interact_input')
export class widget_interact_input extends Component {
    @property(Node) img_number_0:Node = null;
    @property(Node) img_number_1:Node = null;
    @property(Node) img_number_2:Node = null;
    @property(Node) img_number_3:Node = null;
    @property(Node) img_number_4:Node = null;
    @property(Node) img_number_5:Node = null;
    @property(Node) img_number_6:Node = null;
    @property(Node) img_number_7:Node = null;
    @property(Node) img_number_8:Node = null;
    @property(Node) img_number_9:Node = null;
    @property(Node) img_number_xing:Node = null;
    @property(Node) img_number_jing:Node = null;
    @property(Node) img_bg:Node = null;
    @property(Node) input_default:Node = null;
    @property(Node) font_info:Node = null;
    @property(EditBox) editBoxAnswer:EditBox = null;
    private m_data:interact_input_data = null;
    public initView(data:interact_input_data){
        this.m_data = data;
        this.img_number_0.getComponent(receive_widget_item).updateView(this.m_data.att_0)
        this.img_number_1.getComponent(receive_widget_item).updateView(this.m_data.att_1)
        this.img_number_2.getComponent(receive_widget_item).updateView(this.m_data.att_2)
        this.img_number_3.getComponent(receive_widget_item).updateView(this.m_data.att_3)
        this.img_number_4.getComponent(receive_widget_item).updateView(this.m_data.att_4)
        this.img_number_5.getComponent(receive_widget_item).updateView(this.m_data.att_5)
        this.img_number_6.getComponent(receive_widget_item).updateView(this.m_data.att_6)
        this.img_number_7.getComponent(receive_widget_item).updateView(this.m_data.att_7)
        this.img_number_8.getComponent(receive_widget_item).updateView(this.m_data.att_8)
        this.img_number_9.getComponent(receive_widget_item).updateView(this.m_data.att_9)
        this.img_number_xing.getComponent(receive_widget_item).updateView(this.m_data.att_xing)
        this.img_number_jing.getComponent(receive_widget_item).updateView(this.m_data.att_jing)
        this.font_info.getComponent(receive_widget_item).updateView(this.m_data.font)
        this.img_bg.getComponent(receive_widget_item).updateView(this.m_data.bg)
        this.input_default.getComponent(receive_widget_item).updateView(this.m_data.input_default)
        this.editBoxAnswer.string = this.editBoxAnswer.string;
        this.editBoxAnswer.node.on('editing-did-ended',()=>{
            this.m_data.answer = this.editBoxAnswer.string;
            ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.m_data,config.attributes_list_type.top)
        })
    }
}


