[Project_owners] nsISelectionController

HJ bugs4hj at netscape.net
Mon Jul 18 13:12:43 EDT 2005


Eric Jung wrote:
> That's an interesting approach. I've been hiding the tree altogether
> with a <deck/>... didn't know about nsISelectionController.

There are many different solutions for this 'problem' but I don't think 
that you need a deck for it. For example: you can set attribute 
'disabled' to 'true' and use something like this:

#treeID[disabled] > treechildren {
   background-color: -moz-Dialog;
}

but that would still fire the onselect event so you also need this:

tree.view.selection.selectEventsSuppressed = true;

but you can also use something like:

function onClick(aEvent)
{
   var onclickRow = tree.treeBoxObject.getRowAt(aEvent.pageX, aEvent.pageY);
   tree.view.selection.clearRange(onclickRow, onclickRow);
   tree.currentIndex = -1;
}

in combination with: <tree...onclick="onClick();"...

or you can use something like this:

function onClick(aEvent)
{
   var onclickRow = tree.treeBoxObject.getRowAt(aEvent.pageX, aEvent.pageY);

   if (aEvent.ctrlKey) {
     var parentIndex = tree.treeBoxObject.view.getParentIndex(onclickRow);

     if (parentIndex >= 0 && tree.view.selection.isSelected(parentIndex)) {
       tree.view.selection.clearRange(onclickRow, onclickRow);
       tree.currentIndex = parentIndex;
     }
   }
   else
     tree.currentIndex = onclickRow;
}

to block users from selecting container children when the container is 
selected. However, this will still 'flash' the selection on/off, and 
that's what I'm trying to solve ;)

I hope this help you, or anyone else...

Happy coding,
/HJ


More information about the Project_owners mailing list