How to "disable" the Context Menu

Monkey Targets Forums/Flash/How to "disable" the Context Menu

therevills(Posted 2011) [#1]
If you want to disable the Adode Context Menu (well nearly!), you need to alter the MonkeyGame.as in your Monkey/targets/flash folder and add the following command in the onAddedToStage function:

stage.showDefaultContextMenu = false;


So it looks like this:

		private function onAddedToStage( e:Event ):void{
		
			try{
				stage.showDefaultContextMenu = false; 

				bbInit();
				bbMain();

				if( runner!=null ) runner();

			}catch( err:String ){
			
				showError( err );

			}
		}


Then delete your build folder and recompile your game.

Right click on the Flash Window and now it should only show:
* Settings
* Global Settings
* About ...


Xaron(Posted 2011) [#2]
Thanks! Need that for BFG!


therevills(Posted 2011) [#3]
Need that for BFG!


I know, thats why I did it ;)


Soap(Posted 2011) [#4]
If you host the game on your own site then you can also add some Javascript to the page which captures the right click and makes it so in most browser the menu doesn't appear at all. :)


Volker(Posted 2011) [#5]
Has anyone got this running with and older version of monkey?
I'm using V44 and really don't want to switch to a higher version
with a 99.9% finished and tested project.

There is no onAddedToStage() in targets/flash/MonkeyGame.as
and just copy&paste gives me an
undedfined 'method showError( err );'
If I remove this, it compiles but the context menu is still shown.