ContextMenu Addon


I am exploring ways to introduce a contextmenu in my application. There’s a screen for which it would enrich the user experience to activate contextual options, rather than clicking on a button panel.

I discovered this address in a quick search which refers to a contextmenu, but I presume it is referred to another logic?

What I am looking for is a way to enable the user right-clicking upon a screen element (mostly a label or image) and display a set of options depending on the element background logic.

I have searched for a contextmenu in the addon marketplace with no luck.

On the other hand I sort of implemented a similar logic with the PopupView widget, however I am not being able to position easily the popup element right beneath the triggering element.

Any ideas?

Many thanks.



You can use ContextMenu extension. To apply it for components you should use unwrap() or withUnwrapped() methods. For instance:

private Label<String> label;

private Notifications notifications;

public void onInit(InitEvent event) {
    label.withUnwrapped(JmixLabel.class, jmixLabel -> {
        ContextMenu contextMenu = new ContextMenu(jmixLabel, true);
        contextMenu.addItem("Item 1", selectedItem -> {
                    .withCaption(selectedItem.getText() + "- clicked")