How do I detect that Drag and Drop operation ended

2019-08-15 21:02发布

问题:

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.