You'd have to test whether MenuBar.getElement().isOrHasChild(Element.as
(event.getNativeEvent().getEventTarget()))
> - Is there another way to deal with my problem ?
Why not use event bubbling (aka event delegation) instead of event
capture? i.e. either:
- put the Grid into a FocusPanel and addKeyDownHandler(...)
- extend Grid and addDomHandler(..., KeyDownEvent.getType())
(eventually implementing HasKeyDownHandlers if you don't want to
handle the KeyDown within the Grid but in the widget that uses the
Grid)
The user would "just" have to click the Grid (or FocusPanel) to have
her keyboard interact with the grid (i.e. as soon as she clicks the
MenuBar or anywhere outside the grid, the handler is no longer called)