如何检测拖放操作已结束?
这是参考我的其他问题
当拖放操作提前结束时,如何检测并分派事件? 我需要知道用户不再拖动项目。即使dragDrop 和dragComplete 事件不会触发。这几乎就像我需要向 DragManager 添加一个事件侦听器一样,但这实际上是不可能的......是吗?
This is in reference to My Other Question
How do can you detect and dispatch an event when a drag and drop operation ends prematurely?
I need to know that the user is no longer dragging an item. Even if the dragDrop and dragComplete events do no fire. Its almost as if I need to add an event listener to the dragManager, but that's not really possible... is it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来基本上您需要能够判断 DragManager 是否崩溃。即使拖/放系统中存在错误事件(我没有见过,但也许我错过了一些明显的事情),您可能也不能总是指望它。
有点像试图设置一个客户端来知道服务器何时死亡之类的事情,是吗?
我可能离得很远,但我想你可以在开始拖动时添加一个 mouseMove 侦听器,并不断检查是否仍在拖动。我相信您可以动态设置 mouseMove 事件触发的频率。
当然,一旦您完成了拖动(无论是成熟还是过早),请删除 mouseMove 侦听器。
我真的并不热衷于做这样的事情。将保姆添加到操作中。但我认为它会做需要做的事情,而且我认为它不需要变得混乱。
It looks like basically you need to be able to tell if the DragManager craps out. Even if there was an ERROR event in the drag/drop system (there isn't that I've seen, but maybe I've missed something obvious), you probably couldn't always count on it.
Sort of like trying to set up a client to know when the server has died kind of thing, yeah?
I may be way off, but I'm thinking you could add a mouseMove listener when you begin your drag and constantly check to see if you are still dragging. I believe you can dynamically set how often that mouseMove event fires.
And, of course, once you complete the drag - whether maturely or prematurely - remove the mouseMove listener.
I'm really not crazy about doing something like this. Adding a babysitter to an operation. But I think it'd do what needs doing, and I don't think it needs to be messy.
对于Flash Builder 4,尝试使用:
否则,您可以使用舞台事件监听器来监听鼠标移出
For Flash Builder 4, try to use:
Otherwise, you can use a stage event listener to listen for mouse out
监听拖动启动器的 dragComplete 事件类型。
Listen to dragComplete event type of drag initiator.