Layout Click Listener disables Browser Context Menu??

I’d like to have a layout click listener that doesn’t disable the browser context menu. Is this possible at all without creating custom versions of all the layouts?

Is there any particular reason why it disables the context menu?


Unfortunately I can’t think of an “easy” way to prevent this behavior. However, it seems to me that you don’t need to create custom versions of all layouts.

See the class com.vaadin.terminal.gwt.client.ui.ClickEventHandler and its method onContextMenu(ContextMenuEvent event). This is where the default behavior is prevented. You could use GWT’s deferred binding to replace this class with your own implementation in your widgetset. Then you could just do some comparison in that method, e.g. check if the clickEventIdentifier of the ClickEventHandler instance is EventId.LAYOUT_CLICK, you could not call the preventDefault() method.

Note: I haven’t actually tried this but can’t see why it would not work. Also, this would change the behavior for all layout click listeners - if you want configurable behavior then more complex changes are required.

Thanks, that sounds like a good approach. Although I wonder if it would break the cases where the context menu needs to be disabled, behaviour that other components might rely on.

Would be great to have it inbuilt in the layout click listeners :slight_smile:

Thanks, Ryan

I wasn’t able to implement this solution in context of Liferay portal, so I had to implement my own widget, where I overrided ClickEventHandler property into VOrderedLayout class. You can check it