Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to make draggable treechildrens

2 views
Skip to first unread message

Marcos Medrano

unread,
Jan 19, 2009, 7:00:26 PM1/19/09
to dev-te...@lists.mozilla.org
Hi,
I have a tree wich not depends of a RDF or datasource and I want to
make the tree childrens draggables.
Any idea how to do this?

Thanks!
Marcos.

Mariano Cuenze

unread,
Jan 19, 2009, 9:07:54 PM1/19/09
to Marcos Medrano, dev-te...@lists.mozilla.org
On Mon, Jan 19, 2009 at 9:00 PM, Marcos Medrano
<marcosm...@gmail.com> wrote:
> Hi,
> I have a tree wich not depends of a RDF or datasource and I want to
> make the tree childrens draggables.
> Any idea how to do this?

see http://www.xulplanet.com/tutorials/mozsdk/dragdrop.php (and the
related ones). It works for trees too.

--
Mariano

Marcos Medrano

unread,
Jan 20, 2009, 9:28:04 AM1/20/09
to Mariano Cuenze, dev-te...@lists.mozilla.org

Thanks a lot Mariano!

But where should I put the "ondraggesture" property, or how I can do
something like:

<button label="Drag Me"
ondraggesture="nsDragAndDrop.startDrag(event,buttonObserver);

with the treeitems if I don't have them?

I am using a Custom Tree View (implementing the nsITreeView interface).
I can drag XULElements from outside the tree (for example, the text in
a textbox) to the tree, but I can't find a way to drag the treeitems
that I have inside the tree.

I have somthing like this:

var TreeView = new Class({
initialize: function(table){
/* 'table' is a simple Array containing the data of the tree.
*
* table[r] points to the 'r' row of the tree
* table[r][c] points to the cell at 'r' row and 'c' column.
*/
this.table = table;
this.rowCount = table.length;
},
getCellText: function(row, col) {
return this.table[row][col.id];
},
getCellValue: function(row, col) {
return this.table[row][col.id];
},

....

and another class like:

var TreeWidget = new Class({
tree: null,
data: [],
initialize: function(tree){
this.tree = tree;
...
},
addItem: function(item){
this.data.push(item);
},
update: function(){
this.tree.view = new TreeView(this.data);
},
...


Thanks!
Marcos.

Igor Tandetnik

unread,
Jan 20, 2009, 2:16:01 PM1/20/09
to
Marcos Medrano <marcosm...@gmail.com> wrote:
> But where should I put the "ondraggesture" property, or how I can do
> something like:
>
> <button label="Drag Me"
> ondraggesture="nsDragAndDrop.startDrag(event,buttonObserver);
>
> with the treeitems if I don't have them?

You put the event handler on <treechildren> or <tree>. When the event
arrives, you can use nsITreeBoxObject::getCellAt to figure out which
item the user is dragging, or you can just assume the user is dragging
whichever items are currently selected (the latter makes more sense if
you support multiple selection).

Igor Tandetnik


Christophe Charron

unread,
Jan 22, 2009, 4:56:18 AM1/22/09
to

Hi,

you could have a look here :
http://www.novatice.org/xul/demo.php#ancNovatree

--
Cordially,
Christophe Charron
http://xsoftware.fr

0 new messages