Basil Bourque
Basil Bourque

Reputation: 339472

How to jerry-rig a menu bar in Vaadin Flow version 12

Per this forum thread, a proper menubar widget is promised for Vaadin Flow in version 14 for June 2019 next year, according to the Components page in the manual.

Until then, that page suggests a menu bar can be jerry-rigged in version 12 using Select and ContextMenu.

MenuBar

Planned for Vaadin 14. Can be made currently by combining Select (V12) and ContextMenu (V12)

(a) I cannot find either Select or ContextMenu in the version 12 JavaDoc.

(b) Has anyone an example implementation to share?

Upvotes: 0

Views: 157

Answers (1)

cfrick
cfrick

Reputation: 37073

ContextMenu is a transitive dependency in at least 12.0.0.beta1

Some very basic example (Groovy 2.5):

def fileMenu
content.add(
        fileMenu = new Div(new Text("File")).tap{
            style.set('cursor', 'pointer')
        },
)
new ContextMenu(fileMenu).tap{
    openOnClick = true // allows opening with a left-click
    addItem("Open", {println "open"})
    addItem("Save", {println "save"})
}

Given the crude nature of that and the relative ease to add something from webcomponents.org you might be better off with something else. Yet there seems to be just one classic menu bar (https://www.webcomponents.org/element/wiredjs/wired-menu-bar) for mocking UIs.

Upvotes: 1

Related Questions