PDA

View Full Version : Right click disable in IE



nitinfuture
7 Mar 2011, 5:35 AM
Hi,

I am using GXT 2.2.1 jar in my application. I need to disable right click on the browser when i run my application.The browsers I need to use are IE6 and IE8

My code is as follows:

private static Listener<DomEvent> rightClickDisableListener;


private void addRightClickPreventListener(){

rightClickDisableListener = new Listener<DomEvent>(){
public void handleEvent(DomEvent de) {
if(de.isRightClick()){

//methods I have tried to prevent right click pop up from appearing




de.stopEvent();
de.cancelBubble();
de.preventDefault();
de.getEvent().stopPropagation();
de.setCancelled(true);
de.getTargetEl().disableContextMenu(true);

}

}

};

}

My code does not seem to have any effect on the browser in spite of the fact that the browser captures the right click event successfully.The right click pop up still appears after I add the above listener.Please help me solve the problem.
Thanks in advance!


Cheers,
Nitin