Frage

Simple and short question, but I'm not so sure about a good answer. ;)

Is it somehow possible to add a Listener to the root items of a menu bar?

Menu Bar

I'd like to click the Edit item and a event should be fired.

War es hilfreich?

Lösung

From Vaadin API documentation :

You can set commands to be fired on user click by implementing the MenuBar.Command interface.

Create a class that implements MenuBar.Command interface and then add the root item by calling MenuBar.addItem

You can also skip the class creation like this:

myMenuBar.addItem("My Item", new MenuBar.Command() {
    void menuSelected(MenuBar.MenuItem selectedItem) {
        // Handle selection
    }
});

Andere Tipps

If you are doing in xaml, can't you just do in the element, something like <Menu... OnClick="...">

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top