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

Thanks Henri, this solution works. I had to use CSSLayout in place of VerticalLayout due to width restriction on ToolBox.