Displaying browser context menu


I have a small window component that is opened by clicking an icon in the main window, and should be closed by either clicking an item inside the window component or by clicking anywhere in the surrounding window. I have solved the latter by adding a click listener to the main window so that any left click there closes the smaller window.

However, now the standard browser context menu can’t be displayed at all on the application. Only if I don’t add the click listener at all to the main window will the context menu be displayed. I also tried adding and removing the listener depending on the smaller window state, but that didn’t work either.

Any ideas how I could get the browser context menu to open on right click, and at the same time keep the mentioned closing method for the smaller window?


When you add a ClickListener in your Window, it will prevent the default behviour of showing the context menu by right-click. Only way to bypass this is to customize client side
class and to create a new custom component extending
. Learn more at
Vaadin Book Chapter 11.

Have you check out how
PopupView component
suits your case.

Hi, thank you for your reply.

Yes, PopupView was one option we considered for the current “small window” solution. I believe it was discarded as too simple for the requirements, we needed the small window to contain customized data objects, which it was incapable of. The small window now contains buttons that open different views depending on the data assigned to the button. But that is a completely different case. Too bad the ClickListener prevents the default behaviour in the browser. Extending the main window component to get the default behaviour back seems a bit too much work for a small annoyance like this. Thanks anyway :slight_smile:


I just thought I’d point out that PopupView can contain anything that a Window can - just use a Container as the main component. There are other advantages to Window, certainly , but complexity of contents is not one!