views:

1003

answers:

2

I am building an AJAX web app with GWT, and I want to use right-click for various things, just like in a desktop app. However, right-click produces the standard Web context menu and void onClick(ClickEvent event) never gets called. Has anyone figured out how to get this to work? thanks!

+3  A: 

It turns out you can do it by extending DeckPanel. Here's an excellent discussion, along with a nice demo that proves it works.

http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/

ire_and_curses
A: 

Although there are ways of doing it I believe the GWT team had a debate about this and decided enabling right click in a web app was a bad thing and so made the concious decision not to support it. The argument was that right click should continue to work as expected (bring up the host browser's right click context menu) and overriding this was breaking that expected behaviour and that and would be bad practice. While I have had instances where a right click context menu would be useful generally I tend to agree with the GWT team's decision.

Daniel Vaughan
I couldn't disagree more. I would guess that the majority of GWT devs use GWT in an attempt to better emulate the desktop experience. And that includes contextual (right) clicks. There are many enterprise apps where it makes sense to use right clicks.
JP
I know what you mean, I got quite frustrated that right click was missing at first but after reading the GWT team's argument I slowly came round.
Daniel Vaughan
@Daniel Vaughan: Interesting point. I would vote this up if you added a link to the GWT discussion you mention.
ire_and_curses