[Project_owners] Drag and drop to reorder a custom tree view

Malte Kraus firefox at maltekraus.de
Tue Jan 30 09:15:09 PST 2007


David Murray wrote:
> Yep, what the subject says. I've got a one column custom tree view built 
> from an array, and I want to be able to drag the rows up and down to 
> reorder the tree/contents of the array.
Yeah, I'm going through this hell right now as well. :-( (Though with a 
hierarchical tree which makes things even more complicated...)

I think, you have to include this script in your XUL file:
<script type="application/x-javascript"
         src="chrome://global/content/nsDragAndDrop.js"/>
and edit the treechildren node like this:
<treechildren id="engineChildren" flex="1"
               ondraggesture="nsDragAndDrop.startDrag(event, 
gDragObserver);"/>

Then, you'll have to define the gDragObserver object referenced above in 
your JavaScript file and modify your tree view to support drag & drop. 
Have a look at how Mozilla did it:
http://lxr.mozilla.org/mozilla1.8/source/browser/components/search/content/engineManager.js#170
http://lxr.mozilla.org/mozilla1.8/source/browser/components/search/content/engineManager.js#392
http://lxr.mozilla.org/mozilla1.8/source/browser/components/search/content/engineManager.js#438


malte



More information about the Project_owners mailing list