1
votes


I am using dojo 1.5. When I right click on dojo tree my right click pop up menu does not get created as first I need to select the treenode.
Is there any way of selecting a treenode when you right click on the dojo tree node?

1
Why would you want to do that? - Layke
Problem is: First I need to select the tree node and then only my right click menu opens.If I directly right click on the tree node,I don't get the treenode scope.So when some node is selected and u right click on another treenode I get the popup menu for the selected node and not for the required node.Is there any solution to solve this problem? - harris

1 Answers

0
votes

There is no out of the box way to do this, but you can achieve this by adding an event handler for mouse down

dojo.connect(this.tree, 'onMouseDown', lang.hitch(this,this.onTreeRightClick));

onTreeRightClick : function(event)
{
    if(event.button=="2"){
        var node = dijit.getEnclosingWidget(event.target);
        var nodes=this.tree.selectedNodes;
        if(nodes.indexOf(node)>-1)
            return;//if the node is already selected do not alter selected nodes.
        this.tree._setSelectedNodeAttr(node);
    }
}