Workaround for missing context menu for MenuBar/MenuBar.Item?

Hi there

Is it possible that there is no straight forward way to add context menus for MenuBar resp. for MenuBar.Item?
Maybe I’m just blind, but I was looking for it now quite a bit and didn’t find any easy solution.

For me it is hard to understand why components such as tables and trees offer “build-in” support for context menus (using the
addActionHandler(Action.Handler handler)
method, as explained e.g. in the
Vaadin Sampler
), but MenuBar and MenuBar.Item do not.

I saw that there exists a
ContextMenu add-on
for Vaadin. However, since I would like to have the context menu only on the MenuBar and its items, it seems like quite a bit of work to go with this add-on. Since MenuBar.Item does not support adding any kind of listeners (as far as I know), I would need to register the listener that opens the context menu (e.g. on a right click) for the whole MenuBar. But in order to adapt the context menu items according to the MenuBar.Item in question, I would need to decide based on the X and Y coordinates of the ClickEvent which MenuBar.Item the user wants the context menu for?! for me this seems to be a lot of work and might result in flawy code…

So the best solution I figured out so far is to avoid using the MenuBar at all and imitate its behaviour using components like tables and/or trees that - as mentioned above - support context menus. However, this somehow contradicts my instincts as MenuBar itself comes with a whole bunch of handy features…

Therefor my question: am I missing something? or has anybody here an idea how this could be done in an easier and more appropriate way?
Any input is more than welcome!

Thanks already
sv