Created on 2005-07-22 by Paul Sowden.
DragSource
Interface
DragObject
Interface
DropTarget
Interface
Drag and Drop intro.
Drag and Drop involves 3 interfaces:
DragSource
DragObject
DropTarget
These can be implemented by objects. There exists a set of implementations provided to do certain tasks (eg. reordering, moving). Probably in more than 50% of cases the DragSource
and DragObject
interfaces are implemented on the same JS Object (or DOM Node) -- ie. the source is the thing being dragged. Only in more complex widgets where several types can be dragged out or widgets such as the date picker will they be different.
Markup syntax; two attributes dojoDrag
and dojoDrop
. The values of these attributes are "drag types". The tags cause the DOM Nodes to inherit a certain provided implementation, where the DragSource
and DragObject
interfaces both exist on the drag source.
draggin
The three interfaces correspond to the three stages of a drag and drop operation, the start (onmousedown
and sometimes hold), the middle (onmousemove
) and the end (onmouseup
).
DragSource
InterfaceThis interface needs to provide ways to:
DragObjects
, default is the DragSource
DropTarget
can call to inform what it has done with the drop, allowing the DragSource
to update itself.
interface DragSource { DragObject ondrag(in DragEvent event); };
DragObject
InterfaceThis interface allows the object to define what happens to it during movement, which will mostly be constraining.
interface DragObject { readonly attribute String[] dragTypes; Node getDragIcon(); // usually defaults to cloneNode };
DropTarget
InterfaceDragObject
is over the target. These should be used to indicate whether a drop will occur and where possible an indication of what the result of the drop will be.
interface DropTarget { readonly attribute String[] acceptedDragTypes; // corresponding to the mouseover, mousemove and mouseout void ondragover(in DragEvent event); void ondragmove(in DragEvent event); void ondragout(in DragEvent event); void ondrop(in DragEvent event); };
There should be a set of provided implementations which allow a developer to get off the ground with common use cases with a very small amount of effort. There should be at least as little and prefferably less code required to do the same effects as existing drag libraries, as a gauge of how well ours works.
When I get the undo manager polished off we should also provide undo/redo of drag and drop actions by default. Put that in your pipe and smoke it.
draggable
attribute. Clean but limited in the exact same way as the DOM.