Tree event handler in GWT 1.6
Posted by igormoochnick on 04/28/2009
The documentation was a little sparse so, if you’d like to subscribe to the click events on the tree nodes you need to add a selection handler.
This is how you add a selection handler to the whole tree:
Tree optionsTree = new Tree();
optionsTree.addSelectionHandler(new SelectionHandler()
{
@Override
public void onSelection(SelectionEvent event)
{
Window.alert(event.getSelectedItem().getText());
}
});




PVLebret said
This is better :
arbre.addSelectionHandler(new SelectionHandler()
{
public void onSelection(SelectionEvent event)
{
Window.alert(event.getSelectedItem().getText());
}
});
igormoochnick said
I, personally, like to use the @Override annotations when I override and/or inherit functions. Just a simple visualization kick.
Leon said
very helpful, thank you!
igormoochnick said
You’re welcome.