If have a Canvas wit开发者_开发百科h elements on it where a right-click should open a menu for this element. This works fine in IE. In Mozilla it only works as long a no scrollbar is visible. If I smallen the window the menu won't show up even though the event is called. I tried the menu.show(), menu.showContextMenu() and menu.showNextTo() method but neither worked. The simple code snippet looks like this. Is there a reason why this is happening?
final Menu appMenu = new Menu();
MenuItem smallItem = new MenuItem("Test");
appMenu.addItem(smallItem);
// Context Menu open
this.addRightMouseDownHandler(new RightMouseDownHandler() {
@Override
public void onRightMouseDown(RightMouseDownEvent event) {
appMenu.show();
// appMenu.showNextTo(Canvas.this);
System.out.println("rmb");
event.cancel();
}
});
Use canvas.setContextMenu(appMenu)
.
精彩评论