[LayaAirIDE 2.0]Laya的Dialog上如果有按钮 我希望点击到按钮或者其他可以相应的控件 不会触发拖动效果

已邀请:

三尺光阴

赞同来自:

希望dialog中点击到或者相应到其他组件事件的时候 不要触发拖动效果。而点击其他区域没有相应事件的地方才可以拖动

三尺光阴

赞同来自:

心好累。本来自己写的view处理过拖动 后来才发现有dialog想用  结果并不能满足自己需求。于是最后发现了还不如自己处理相关的部分。
核心就是如下方法:
public setCanDrag(canDrag:boolean)
{
this.m_CanDrag = canDrag;
if(this.m_CanDrag)
{
this.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
}
else
{
this.off(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
}

onMouseDown(e: Laya.Event)
{
// console.log(e.currentTarget, e.target);
if(e.target == this)
{
this.startDrag();
}
else
{
this.stopDrag();
}
}
 
判断一下点击对象是否是自己。才处理拖动。

要回复问题请先

商务合作
商务合作