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

@ccclass('widget_interact_puzzle')
export class widget_interact_puzzle extends Component {
    @property(Node) img_bg:Node = null;
    @property(Node) content:Node = null;
    private m_data:interact_puzzle_data = null;
    @property(EditBox) editBoxAnswer:EditBox = null;
    public initView(data:interact_puzzle_data){
        this.m_data = data;
        this.img_bg.getComponent(receive_widget_item).updateView(this.m_data.bg)
        this.content.getComponent(receive_widget_item).updateView(this.m_data.content)
        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)
        })
    }
}


