Jump to:
Type: integer

Set to the row index of the tree caret in the tree. For trees with focus, the caret's position is indicated by the focus ring, but unfocused trees won't show  a focus ring, naturally. For unfocused trees, the (undrawn) caret's position can still be obtained by this property. If the caret isn't present for any row (for example, because the tree has never been focused), the value will be -1.

You cannot rely on this property to change or determine a tree selection, except for trees with seltype="single". (All trees have seltype="multiple" by default.) To reliably change or determine a selection, instead use the nsITreeSelection interface methods available via tree.view.selection.


// One way of retrieving the text of a cell.
<script language ="javascript">
function treeRowClicked(){
    var tree = document.getElementById("my-tree");
    var selection = tree.view.selection;
    var cellText = tree.view.getCellText(tree.currentIndex, tree.columns.getColumnAt(0));

<tree id="my-tree" seltype="single" onselect="treeRowClicked()">
    <treecol label="Title" flex="1"/><treecol label="URL" flex="1"/>
        <treecell label="joe@somewhere.com"/>
        <treecell label="Top secret plans"/>
        <treecell label="mel@whereever.com"/>
        <treecell label="Let's do lunch"/>

See also

Document Tags and Contributors

Contributors to this page: Sheppy, trevorh, Sevenspade, Marsf, MarkFinkle, Ptak82, Pmash, The Hunter, Dria
Last updated by: Sheppy,