How do I detect that Drag and Drop operation ended?

試著忘記壹切 提交于 2019-12-11 05:23:16

问题


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?


回答1:


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.




回答2:


For Flash Builder 4, try to use:

DragEvent.DRAG_EXIT

Otherwise, you can use a stage event listener to listen for mouse out

stage.addEventListener(MouseEvent.MOUSE_OUT...



回答3:


Listen to dragComplete event type of drag initiator.



来源:https://stackoverflow.com/questions/2202071/how-do-i-detect-that-drag-and-drop-operation-ended

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!