Places:Drag & Drop: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
 
Line 10: Line 10:
== Controller Drop Handling Helper ==
== Controller Drop Handling Helper ==


The PlacesControllerDragHelper provides an <code>onDrop</code> method that performs view-agnostic drop handling. This method performs the following actions:
The <code>PlacesControllerDragHelper</code> provides an <code>onDrop</code> method that performs view-agnostic drop handling. This method performs the following actions:


# Determine what mime types of objects are being dragged (from the dragged transferable), and compares this list of types supported as droppable by the target view (<code>peerDropTypes, childDropTypes</code>).
# Determine what mime types of objects are being dragged (from the dragged transferable), and compares this list of types supported as droppable by the target view (<code>peerDropTypes, childDropTypes</code>).
# For each dropped item, unwrap the data, generate insertion or copy transactions, and execute the transactions on the transaction manager.
# For each dropped item, unwrap the data, generate insertion or copy transactions, and execute the transactions on the transaction manager.

Revision as of 00:47, 4 April 2006

Tree Drop Handling

The Places Tree View (tree.xml) implements nsINavHistoryResultViewObserver, which provides a method onDrop which is called by the view when a drop occurs. When this happens, the following steps occur:

  1. Check whether or not the drop is valid by calling the canDrop method, returning silently if it is not.
  2. Determine how many new items will be inserted into open folders in the tree view after the drop completes.
  3. If the drag and drop operation occured within the same view, adjust the insertion index to account for the fact that items may have been removed before it.
  4. Call the controller's onDrop helper.

Controller Drop Handling Helper

The PlacesControllerDragHelper provides an onDrop method that performs view-agnostic drop handling. This method performs the following actions:

  1. Determine what mime types of objects are being dragged (from the dragged transferable), and compares this list of types supported as droppable by the target view (peerDropTypes, childDropTypes).
  2. For each dropped item, unwrap the data, generate insertion or copy transactions, and execute the transactions on the transaction manager.