IDE制作的ui文件:

部分代码:
constructor() {
super();
//渲染监听 与 选中监听(tabList:列表左边的var ; itemList:列表右边的var)
this.tabList.renderHandler = Laya.Handler.create(this, this.tabRenderHandler,null,false);
this.tabList.selectHandler = new Handler(this, this.tabSelectHandler,null,false);
this.itemList.renderHandler = Laya.Handler.create(this, this.itemRenderHandler,null,false);
this.itemList.selectHandler = new Handler(this, this.itemSelectHandler,null,false);
}
private itemRenderHandler(item: serverListItemTest, index: number): void { 。。。}
private itemSelectHandler(index: number): void { 。。。}
private tabRenderHandler(item: serverTabItems, index: number): void {。。。。}
private tabSelectHandler(index: number): void { 。。。}
效果图:

理想效果:切换左边的列表,进行切换右边的列表数据
实际效果:点击页面完全没有反应,监听函数 itemSelectHandler 和 tabSelectHandler都没有执行
问题原因:对应的列表list没有设置接受鼠标点击事件
看下面图片:

原因解析:
mouseEnabled:是否接受鼠标事件
设置为true后,页面的list才能接受鼠标点击事件,selectHandler才能够监听到对应列表项是否被点击
网友评论