Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How do I disable an img context menu?

    SmartGWT 2.2

    I need to disable the right-click context menu on an image, but no matter what I try, the menu persists. Here is what I believe I am supposed to do:

    Code:
    	private void addEvent(final GWTSector gwtSector, Img sectorImg) {
    //		sectorImg.setContextMenu(new Menu());
    		sectorImg.addRightMouseDownHandler(new RightMouseDownHandler() {
    			public void onRightMouseDown(RightMouseDownEvent event) {
    				StatusReporter.setText("selecting "
    							+ gwtSector.coords);
    				event.cancel();
    			}
    		});
    If I uncomment sectorImg.setContextMenu(new Menu()); then I get a one-line context menu that says "Empty Menu", but I want NO right-click context menu.

    I assume the event.cancel() is supposed to stop the context menu from appearing, but I guess it isn't working? The menu that's coming up is the browser image context menu (save image as... etc.)

    Thanks!
    Ken

    #2
    Try adding a addShowContextMenuHandler(..) and call event.cancel() to disable the native browser context menu.

    Please post Smart GWT related questions in the Smart GWT forum.
    Last edited by sjivan; 12 Oct 2010, 00:33.

    Comment


      #3
      Thanks! That did the trick!

      For the benefit of other readers, what he means is to add the following lines:

      Code:
      		sectorImg.addShowContextMenuHandler(new ShowContextMenuHandler() {
      			@Override
      			public void onShowContextMenu(ShowContextMenuEvent event) {
      				event.cancel();
      			}
      		});

      Comment


        #4
        but the context menu will appear when the imag is disabled ??? (ImgButton)

        how can i fix that ???

        Comment

        Working...
        X