I'm trying to disable the right-click context menu for all windows/controls by default.
I am able to create an addShowContextMenuHandler to Window.setDefaultProperties to trap this and call event.cancel(). This works for all controls that are enabled. However, I also want to do this for disabled controls because I don't want the browser context menu to be displayed. I also tried adding an addRightMouseDownHandler but this isn't called for disable controls either.
How can I do this?
Version:
Isomorphic SmartClient Framework (v8.2p_2012-08-08/PowerEdition Deployment 2012-08-08)
In the sample code below, the context menu does not appear for the enabled button, but it does for the disabled button.
I am able to create an addShowContextMenuHandler to Window.setDefaultProperties to trap this and call event.cancel(). This works for all controls that are enabled. However, I also want to do this for disabled controls because I don't want the browser context menu to be displayed. I also tried adding an addRightMouseDownHandler but this isn't called for disable controls either.
How can I do this?
Version:
Isomorphic SmartClient Framework (v8.2p_2012-08-08/PowerEdition Deployment 2012-08-08)
In the sample code below, the context menu does not appear for the enabled button, but it does for the disabled button.
Code:
public class Showcase implements EntryPoint { public class TestWindow extends Window { TestWindow() { super(); this.setIsModal( true ); this.setWidth(500); this.setHeight(100); final HLayout mainLayout = new HLayout(); IButton enabled = new IButton("enabled"); IButton disabled = new IButton("disabled"); disabled.disable(); mainLayout.addMember(enabled); mainLayout.addMember(disabled); this.addItem(mainLayout); } } public Showcase() { super(); Showcase.setDefaultWindowProperties(); } public void onModuleLoad() { Canvas myCanvas = new Canvas(); TestWindow tw = new TestWindow(); tw.show(); myCanvas.draw(); } /** * Configures the default properties for all Windows in the product. * E.g. Window opacity, default context menu, etc. */ private static void setDefaultWindowProperties() { final int opacity = 100; Window windowProperties = new Window(); windowProperties.addShowContextMenuHandler( new ShowContextMenuHandler() { @Override public void onShowContextMenu( ShowContextMenuEvent event ) { event.cancel(); } }); windowProperties.addRightMouseDownHandler( new RightMouseDownHandler() { @Override public void onRightMouseDown( RightMouseDownEvent event ) { event.cancel(); } }); windowProperties.setEdgeOpacity( opacity ); Window.setDefaultProperties( windowProperties ); } }
Comment