[LayaAir 2.0]Button点击函数逻辑bug
onMouse(e) {上面逻辑当clickHander只执行一次的时候逻辑上有bug,Hander的run执行的时候如果只执行一次会被回收,这个时候button又持有引用,如果其他地方用到了这个Handler,点击按钮就会执行到其他地方导致真正该执行的地方无法执行。
if (this.toggle === false && this._selected)
return;
if (e.type === Laya.Event.CLICK) {
this.toggle && (this.selected = !this._selected);
this._clickHandler && this._clickHandler.run();
return;
}
!this._selected && (this.state = Button.stateMap[e.type]);
}
应该修改为:
__proto.onMouse=function(e){
if (this.toggle===false && this._selected)return;
if (e.type===/*laya.events.Event.CLICK*/"click"){
this.toggle && (this.selected=!this._selected);
if(this._clickHandler){
var handler = this._clickHandler;
if(handler.once){
this._clickHandler = null;
}
handler.run();
}
return;
}
!this._selected && (this.state=Button.stateMap[e.type]);
}
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
Aar0n
赞同来自: