12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { _decorator, Component, Node } from 'cc';
- import { ui_att_item } from '../../../data/data';
- import { receive_res_item } from '../uiWidget/receive_res_item';
- import { receive_widget_item } from '../uiWidget/receive_widget_item';
- import { tools } from '../../tools';
- import { config } from '../../config';
- const { ccclass, property } = _decorator;
- @ccclass('question_btn_info')
- export class question_btn_info extends Component {
- @property(Node) res_node:Node = null;
- @property(Node) att_node:Node = null;
- @property(Node) btn_delete:Node = null;
- private m_data:ui_att_item = null;
- private m_index:number = 0;
- private m_call_back = null;
- public initView(data:ui_att_item,index:number,call,type){
- this.m_data =data;
- this.m_call_back = call;
- this.m_index = index;
- if(type===config.attributes_list_type.question_select){
- this.btn_delete.active = true;
- }else{
- this.btn_delete.active = false;
- }
- this.res_node.getComponent(receive_res_item).initView(this.m_data,type)
- this.att_node.getComponent(receive_widget_item).updateView(this.m_data,type)
- this.btn_delete.off(Node.EventType.TOUCH_END)
- this.btn_delete.on(Node.EventType.TOUCH_END,()=>{
- if(this.m_call_back!=null){
- tools.show_dialog("确定删除此按钮?",()=>{
- this.m_call_back(this.m_index)
- this.node.destroy()
- this.node.removeFromParent()
- })
- }
- })
- }
- protected onDestroy(): void {
- this.res_node.destroy()
- this.att_node.destroy()
- }
- }
|