GXT (Ext GWT) - How can I disable the browser's default right click response?

1. Using the GXT (Ext GWT) library from the ExtJS is very simple.

You can write a static function like this:
* Disable the browser's default right click response.
public static void disableDefaultContextMenu() {
new Listener() {
public void handleEvent(ComponentEvent be) {

and you call it first thing in your "onModuleLoad()" function.

Now, all default right-click menus are gone, and only the ones defined by your application will appear.

2. For pure GWT implementation try this:
- first define the static function:
* Returns the document element.
public static native com.google.gwt.user.client.Element getDocElement() /*-{
return $doc;

- and then call this code first thing in the "onModuleLoad()":
Event.addNativePreviewHandler(new Event.NativePreviewHandler(){
public void onPreviewNativeEvent(NativePreviewEvent event) {
if (event.getTypeInt() == Event.ONCONTEXTMENU){
DOM.sinkEvents(getDocElement(), Event.ONCONTEXTMENU);

I hope you'll be happy after that...


1 comment:

  1. I’m not sure where you are getting your info, but great topic. I need to spend some time learning much more or understanding more. Thanks for fantastic information.
    website design