attributes_text_sound.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { _decorator, Component, EditBox, Label, Node, Toggle } from 'cc';
  2. import { att_text_sound_data } from '../../../data/data';
  3. import { receive_sound_item } from '../uiWidget/receive_sound_item';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('attributes_text_sound')
  6. export class attributes_text_sound extends Component {
  7. @property(Node) edit_text:Node = null;
  8. @property(Node) sound:Node = null;
  9. @property(Node) edit_y:Node = null;
  10. @property(Toggle) toggle:Toggle = null;
  11. private call_back = null;
  12. private m_data:att_text_sound_data = null;
  13. public initView(call){
  14. this.call_back = call;
  15. this.edit_text.on('editing-did-ended',()=>{
  16. this.change()
  17. })
  18. this.edit_y.on('editing-did-ended',()=>{
  19. this.change()
  20. })
  21. this.toggle.node.on(Toggle.EventType.TOGGLE,()=>{
  22. this.change()
  23. })
  24. }
  25. change(){
  26. this.m_data.pos_y = parseInt(this.edit_y.getComponent(EditBox).string)
  27. this.m_data.text = this.edit_text.getComponent(EditBox).string;
  28. if(this.m_data.is_open_click_close==undefined){
  29. this.m_data.is_open_click_close = true;
  30. }
  31. this.m_data.is_open_click_close = this.toggle.isChecked
  32. if(this.call_back!=null){
  33. this.call_back(this.m_data)
  34. }
  35. }
  36. public update_att(data:att_text_sound_data){
  37. this.m_data = data;
  38. this.edit_text.getComponent(EditBox).string = this.m_data.text;
  39. this.sound.getComponent(receive_sound_item).updateView(this.m_data.sound_data)
  40. this.edit_y.getComponent(EditBox).string = this.m_data.pos_y.toString()
  41. if(this.m_data.is_open_click_close==undefined){
  42. this.m_data.is_open_click_close = true;
  43. }
  44. this.toggle.isChecked = this.m_data.is_open_click_close
  45. }
  46. }