Here is an example of how this works.
Here is the function we want to call when selecting node:
var sel = function(oEvent) {
console.log(oEvent.getSource().getText() + " selected");
};
And here the tree with some nodes, nodes 1.1 and 1.2 has a handler:
new sap.ui.commons.Tree("tree", {
nodes: [
new sap.ui.commons.TreeNode({
text: "1",
nodes: [
new sap.ui.commons.TreeNode({
text: "1.1",
selected: sel
}),
new sap.ui.commons.TreeNode({
text: "1.2",
selected: sel
})
]
}),
new sap.ui.commons.TreeNode({
text: "2"
})
]
}).placeAt("content");
( ):
newNode = sap.ui.getCore().byId("tree").getNodes()[0].getNodes()[0]
newNode.select()
1.1 selected
, node.