Friday, 5 November 2010

Design for drag image

Well had implemented the drag image as supported by DnD but ...
It doesn't work on Windows, and ...
It doesn't allow you to snap to grid on the drop target, essentially as the drop target can't get hold of the image or alter it's location in any way. It may be possible to do the following:
When the drag operation enters a component which has registered itself as a drop target and listener, dragEnter can extract the transferable, get the transfer data, instantiate the object, grab the drag image from it (as thats implemented in my source component), store that ghosted image in the target component, and then as dragMove is called (or whatever the motion listener is), it can paint the image. When dragExit is called it nulls the ghost image and we're back to square 1.
Must remember to null the ghost on successful drop.
This way the overheads of creating the image only happen when the cursor enters the component, not on every move.

No comments:

Post a Comment