12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import { _decorator, Component, EditBox, Node } from 'cc';
- import { ui_att_item } from '../../../data/data';
- import { Attributes } from '../Attributes';
- import { config } from '../../config';
- import { ClientEvent } from '../../clientEvent';
- const { ccclass, property } = _decorator;
- @ccclass('receive_widget_item')
- export class receive_widget_item extends Component {
- private m_data:ui_att_item = null;
- private widget_type = config.attributes_list_type.top;
- private call_back = null;
- public initView(call){
- this.call_back = call;
- }
- updateView(data:ui_att_item,type=config.attributes_list_type.top){
- this.widget_type = type;
- if(this.m_data===null){
- this.node.getChildByName("x").on('editing-did-ended',()=>{
- this.change()
- })
- this.node.getChildByName("y").on('editing-did-ended',()=>{
- this.change()
- })
- this.node.getChildByName("w").on('editing-did-ended',()=>{
- this.change()
- })
- this.node.getChildByName("h").on('editing-did-ended',()=>{
- this.change()
- })
- }
- this.m_data = data;
- let x= this.getX()
- let y = this.getY()
- let width = this.getWidth();
- let height = this.getHeight();
- x.string = this.m_data.x.toString();
- y.string = this.m_data.y.toString();
- width.string = this.m_data.width.toString();
- height.string = this.m_data.height.toString();
- }
- change(){
- this.m_data.x = parseInt(this.getX().string)
- this.m_data.y = parseInt(this.getY().string)
- this.m_data.width = parseInt(this.getWidth().string)
- this.m_data.height = parseInt(this.getHeight().string)
- // if(this.call_back!=null){
- // // this.scheduleOnce(()=>{
-
- // // },0.5)
- // this.call_back(this.m_data)
- // }else{
-
- // }
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,Attributes.Singleton.get_cur_att_data(),this.widget_type)
- }
- getX():EditBox{
- return this.node.getChildByName("x").getComponent(EditBox);
- }
- getY(){
- return this.node.getChildByName("y").getComponent(EditBox);
- }
- getWidth(){
- return this.node.getChildByName("w").getComponent(EditBox);
- }
- getHeight(){
- return this.node.getChildByName("h").getComponent(EditBox);
- }
- }
|