开发者

Listen to a click on a root item of a menu bar (Vaadin)

开发者 https://www.devze.com 2023-04-03 21:40 出处:网络
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?

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?

Listen to a click on a root item of a menu bar (Vaadin)

I'd like to click the Edit item开发者_如何学运维 and a event should be fired.


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
    }
});


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

0

精彩评论

暂无评论...
验证码 换一张
取 消