Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
ToolBox :: How to prevent default right-click menu VOverlay
Hi,
I want to disable the browser specific right click menu on ToolBox. I tried to capture the click event on VToolboxBase and if its a click event then I execute nativeEvent.preventDefault().
Unfortunately it still brings me the browser's right-click menu. Adding ClickListener to Window also doesn't work as Toolbox is over the Window.
Please let me know what could be the possible way to fix it.
Hi,
To prevent the browser context menu, you can add a LayoutClickListener to the root layout of the Toolbox:
Toolbox tb = new Toolbox();
VerticalLayout vl = new VerticalLayout();
tb.addComponent(vl);
vl.addListener(new LayoutClickListener() {
public void layoutClick(LayoutClickEvent event) {
}
});
-Henri
Henri Kerola:
Toolbox tb = new Toolbox(); VerticalLayout vl = new VerticalLayout(); tb.addComponent(vl); vl.addListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { } });
Thanks Henri, this solution works. I had to use CSSLayout in place of VerticalLayout due to width restriction on ToolBox.