Sencha Premium Member
Unanswered: Will sprites be draggable in the near future?
I have a tree like drawing of a data stream and I want the nodes (represented as rectanglesprites) to be draggable. Is this feature going to be possible?
Sprites aren't draggable in GXT the same way that Elements are not draggable - but an entire Widget can be made draggable with the Draggable class.
Some dnd behavior in GXT works on elements directly by listening for specific mouse down events (click), followed by mouse move events (dragging), and finishing in mouse up (drop). In the same way, you can track mouse down on a sprite inside a DrawComponent, then, with every mouse move, update the position of that sprite to follow the movement, and finally stop moving it on mouse up.
To track drags *outside* the draw component, you'll need to copy() the sprite and draw it in a new draw component and move *that* component around the page to follow the mouse. To track those events, consider using an event preview handler on all mouse move events.
If you had built a custom Component that drew Elements on the page, the standard DnD wouldn't work on it, but you could build a DragSource/DropTarget-like class to build this DnD - Draggable wouldn't work. In the same way, you must build DnD that is specific to your Sprite-based DrawComponent. It may be possible to subclass DragSource and DropTarget (see the existing subclasses for examples), but I haven't attempted that myself.