Exit the App
Monkey Targets Forums/Android/Exit the App
| ||
Hi, I have these lines in my program... If KeyHit(KEY_ESCAPE) Then ExittheApp If KeyHit(KEY_F1) Then ExittheApp The KEY_ESCAPE part works fine and is mapped to the BACK key on my Galaxy S2. I read on a post somewhere on monkeycoder that the Menu key should work by using KEY_F1 but it doesn't seem to work. I have also tried every other key code and none of them seem to map to the MENU key. Can anyone offer any advice, thanks. Dan. |
| ||
You need to add code to mojo yourself to get the menu key to work: http://www.monkeycoder.co.nz/Community/post.php?topic=496&post=5093 |
| ||
I have put the code in from your link above, right at the bottom of the MonkeyGame class in the file C:\MonkeyPro\modules\mojo\native\mojo.android.java, but still only the 'back' key on my phone works. The onDestroy code is from the .java file and is there just to illustrate where I added the extra code. As is the last wiggly bracket. @Override public void onDestroy(){ super.onDestroy(); } public boolean onSearchRequested(){ if( app!=null ){ app.input.OnKeyDown( 27 ); app.input.OnKeyUp( 27 ); } return super.onSearchRequested(); } public boolean onCreateOptionsMenu(Menu menu) { if( app!=null ){ app.input.OnKeyDown( 27 ); app.input.OnKeyUp( 27 ); } return true; } } Is this the correct place in the MonkeyGame class? Thanks, Dan. |
| ||
Try putting this:public boolean onSearchRequested(){ if( app!=null ){ app.input.OnKeyDown( 27 ); app.input.OnKeyUp( 27 ); } return super.onSearchRequested(); } public boolean onCreateOptionsMenu(Menu menu) { if( app!=null ){ app.input.OnKeyDown( 112 ); // F1 Key app.input.OnKeyUp( 112 ); } return false; } In the MonkeyView class (C:\MonkeyPro\modules\mojo\native\mojo.android.java): public static class MonkeyView extends GLSurfaceView implements GLSurfaceView.Renderer{ public MonkeyView( Context context ){ super( context ); } public MonkeyView( Context context,AttributeSet attrs ){ super( context,attrs ); } // ----------> New code here <----------- public boolean dispatchKeyEventPreIme( KeyEvent event ){ ... |