import { _decorator, Component, EditBox, Label, Node, Toggle } from 'cc'; import { att_text_sound_data } from '../../../data/data'; import { receive_sound_item } from '../uiWidget/receive_sound_item'; const { ccclass, property } = _decorator; @ccclass('attributes_text_sound') export class attributes_text_sound extends Component { @property(Node) edit_text:Node = null; @property(Node) sound:Node = null; @property(Node) edit_y:Node = null; @property(Toggle) toggle:Toggle = null; private call_back = null; private m_data:att_text_sound_data = null; public initView(call){ this.call_back = call; this.edit_text.on('editing-did-ended',()=>{ this.change() }) this.edit_y.on('editing-did-ended',()=>{ this.change() }) this.toggle.node.on(Toggle.EventType.TOGGLE,()=>{ this.change() }) } change(){ this.m_data.pos_y = parseInt(this.edit_y.getComponent(EditBox).string) this.m_data.text = this.edit_text.getComponent(EditBox).string; if(this.m_data.is_open_click_close==undefined){ this.m_data.is_open_click_close = true; } this.m_data.is_open_click_close = this.toggle.isChecked if(this.call_back!=null){ this.call_back(this.m_data) } } public update_att(data:att_text_sound_data){ this.m_data = data; this.edit_text.getComponent(EditBox).string = this.m_data.text; this.sound.getComponent(receive_sound_item).updateView(this.m_data.sound_data) this.edit_y.getComponent(EditBox).string = this.m_data.pos_y.toString() if(this.m_data.is_open_click_close==undefined){ this.m_data.is_open_click_close = true; } this.toggle.isChecked = this.m_data.is_open_click_close } }