忽略nativeWindow事件监听器
这已经困扰我好几天了,在谷歌搜索后似乎无法得到答案......
问题很简单,
我有一个带有事件监听器的矩形,如下所示:
rect.addEventListener(MouseEvent.MOUSE_DOWN, startMove);
private function startMove(event:MouseEvent):void
{
this.nativeWindow.startMove();
}
这工作正常。
我在这个矩形内还有一个按钮,当我单击该按钮时,窗口会拖动,就像我单击了该矩形一样。
我怎样才能阻止这种情况发生?我尝试删除该事件,但没有用,我什至不知道要删除哪个事件,mouseDown 或 NativeDrag 事件...nativeWindow 中没有 stopDrag() 函数。有一个简单的解决方案吗?
非常感谢任何帮助!
This has been bugging me for days, cant seem to get an answer after googling forever...
Problem is simple,
I have a rectangle with an event listener like so:
rect.addEventListener(MouseEvent.MOUSE_DOWN, startMove);
private function startMove(event:MouseEvent):void
{
this.nativeWindow.startMove();
}
this works fine.
I also have a button inside this rectangle, and when I click the button the window drags just like if I had clicked on the rectangle.
How can I stop this from happening? I tried removing the event but that didn't work, I don't even know which event to remove, the mouseDown or NativeDrag event... There is no stopDrag() function in nativeWindow. Is there a simple solution?
Any help highly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当事件的
目标
(事件的来源)是您正在侦听的调度程序时,您才需要处理该事件。调度程序通过 event.currentTarget 进行标识。因此,您的代码需要如下所示:PS 我注意到您是 Stack Overflow 的新手 - 欢迎!如果您觉得我的回答有用,请务必点赞并通过绿色复选标记接受
You need to only process the event if the event's
target
(where it originated from) is the dispatcher you were listening to. The dispatcher is identified viaevent.currentTarget
. So this is what your code needs to look like:P.S. I notice you're new to Stack Overflow - welcome! If you find my answer useful, please be sure to upvote it and accept it via the green checkmark