简体   繁体   中英

GWT Tree: selection Listener

I'm trying to add a SelectionListener<TreeItem> on my Tree using the addSelectionHadler() method.

For my proof on onSelection(SelectionEvent<TreeIterm> event) I put a simple Windows.alert() but it don't do anything: when I select a treeItem that color change but doesn't open the window.

I write the Handler but if you want more code tell me.

Thank you.

        class SelHand implements SelectionHandler<TreeItem> {

        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            Window.alert(event.getSelectedItem().getText());
        }

    }

    SelHand selezionatore = new SelHand();
    tree.addSelectionHandler(selezionatore);

Use the straightforward:

tree.addSelectionHandler(new SelectionHandler<TreeItem>() {

    @Override
    public void onSelection(SelectionEvent<TreeItem> event) {
        Window.alert(event.getSelectedItem().getText());
    }

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM