我正在尝试使用addSelectionHadler()
方法在我的Tree
上添加SelectionListener<TreeItem>
。
对于我在onSelection(SelectionEvent<TreeIterm> event)
上的证明,我放了一个简单的Windows.alert()
,但它无能为力:当我选择一个颜色变化但没有打开窗口的TreeItem时。
我写处理程序,但如果您想要更多代码告诉我。
谢谢。
class SelHand implements SelectionHandler<TreeItem> {
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
Window.alert(event.getSelectedItem().getText());
}
}
SelHand selezionatore = new SelHand();
tree.addSelectionHandler(selezionatore);
使用直接使用:
tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
Window.alert(event.getSelectedItem().getText());
}
});