R – Implementing drag manually on a Flex List

apache-flexdrag and drop

I have a Flex Application which displays a collection of items in one of several Lists depending on how the item is classified. By dragging items between the lists, the user kicks off a server side process which attempts to reclassify the items. The server side process then returns some XML which either contains an error message or an 'OK'.

The requirement is for the UI to perform a 'drag move' if the server returns OK and no-op if the server returns an error. Using the default drag handlers (setting dragEnabled=true and dropEnabled=true on the Lists) appears to always perform a drag copy.

As far as I could tell, the only way for me to get enough control over things to handle the asynchrous server validation is to implement dragging to and from the lists manually. So I read Adobe's documentation and attempted to adapt their example.

The problem I am having is that, as far as I can tell, I need to detect dragging by hooking up to the mouseMove event on the List. I then pass the List as the initiator to the DragManager.doDrag routine.

Working in this way has a number of problems: the default proxy image is the size of the entire list, attempting to use the scrollbar sets off a drag detection, etc. Clearly I am doing something wrong.

Has anyone tried implementing drag on Lists manually? Is there a quick trick to detecting drag events correctly? Should I be hunting down the actual itemRenderer the user is dragging and passing that as the initiator?

Best Answer

I'm thinking your drag initiator should be the item renderer that you are dragging rather than the entire List control.

Related Topic