Jump to content

[SOLVED] How to disable the ESC key menu


photo

Recommended Posts

Posted

I'd like to "shut away" all the settings for Unigine once we ship, but one thing I can't seem to figure out is how to disable the menu that comes up when the ESC key is pressed. Is there a way in UnigineScript to do so?

Posted

We deactivated it in data/core/scripts/system/system.h:

#ifndef _RUN_MODE_CLIENT
        // show/hide main window  
        if(engine.console.getActivity() == 0 && engine.gui.getMouseGrab() == 0 &&
                engine.gui.getPermanentFocus() == NULL && engine.app.clearKeyState(APP_KEY_ESC)) {

            if(enabled == 0) show();
            else hide();
       }
#endif
Posted

Should also be possible without modifying core scripts. We used something like this in our world script

int init()
{
    ....
    engine.gui.setKeyPressCallback( "keyPressCallback" );
    ....
    
    return 1;
}

.....

int keyPressCallback( int key )
{
    if( key == APP_KEY_ESC )
    {
	engine.app.clearKeyState( key );
        return 1;
    }
    else
    {
        return 0;
    }
}
  • Like 1
Posted

Thank you both, that's excellent.

 

 

Edit: this is the code we ended up using. 

/**
*   Capture and swallow the escape keypress so that the system menu cannot
*   be displayed
**/
int keypress_callback(int keycode) {

    // Don't run if the editor is loaded
    if (engine.editor.isLoaded() == 1) {
        return 0;
    }


    if (keycode == APP_KEY_ESC) {
      // Allow <ESC> to release the cursor if we have grabbed it.
      if (engine.app.getMouseGrab() == 1 ) {
        return 0;
      }else{
        engine.app.clearKeyState(keycode);
        return 1;
      }
    }

    return 0;
}

Posted

There is a method for that in UNIGINE 2:

engine.system.call("systemSetToggle",-1);
  • 1 year later...
Posted

You can also just #define MENU_USER in your unigine.cpp script file, before the include to system.h.

 

#define MENU_USER

 

...
#include <core/scripts/system/system.h>
...

 

This will keep the dialog from popping up at all.  Note that the dialog also pops up with the Windows key.  So just suppressing the ESC key doesn't cut it.

×
×
  • Create New...