开发者

Unable to open right click menu when dojo tree node is not selected

开发者 https://www.devze.com 2023-02-22 02:24 出处:网络
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.

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?


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);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消