Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 12:06, 15 October 2008 by extkbeditor1 (Talk | contribs)

Catching the menu open and close events in Symbian C++

From Wiki
Jump to: navigation, search


Template:KBCS

Article Metadata
Tested with
Devices(s): Nokia 6220 Classic
Compatibility
Platform(s): S60 3rd Edition
Article
Keywords: MEikMenuObserver, MEikMenuObserver::SetEmphasis()
Created: (02 Oct 2008)
Last edited: extkbeditor1 (15 Oct 2008)

Overview

This code snippet shows how to catch the menu open and close events in CAknAppUi-derived classes. These events can be caught by overriding the SetEmphasis() method from MEikMenuObserver. This functionality is needed, for example, when a game must be in pause mode while a game menu is activated.

This snippet can be self-signed.

MMP file

The following libraries are required:

LIBRARY     avkon.lib   //Avkon resources

Header file

#ifndef __TESTAAPPUI_H__
#define __TESTAAPPUI_H__
 
// INCLUDES
#include <aknappui.h>
 
// FORWARD DECLARATIONS
class CTestAAppView;
//class CGameEngine;
 
// CLASS DECLARATION
/**
* CTestAAppUi application UI class.
*/

class CTestAAppUi : public CAknAppUi
{
//...
private: // from MEikMenuObserver
void SetEmphasis(CCoeControl* aMenuWindow,TBool aEmphasis);
//...
//Pauses the application if menu is activated
void SetUiPauseState(TBool aEmphasis);
private:
// Data
 
//The application view
CTestAAppView* iAppView;
 
//The pointer to the game engine
//CGameEngine* iEngine;
};
 
#endif //__TESTAAPPUI_H__

Source file

#include "TestAAppUi.h"
#include "TestAAppView.h"
 
//...
 
// From MEikMenuObserver. Menu emphasising or de-emphasising function.
void CTestAAppUi::SetEmphasis(CCoeControl* /*aMenuWindow*/, TBool aEmphasis)
{
if(iAppView)
{
SetUiPauseState(aEmphasis);
}
}
 
void CTestAAppUi::SetUiPauseState(TBool aEmphasis)
{
 
//pause game if menu is activated
if(aEmphasis /*&& !iEngine->IsStopped()*/)
{
//this debug line works only in the emulator
//iEikonEnv->InfoMsg(_L("stop"));
 
 
//iEngine->StopGame();
}
else
{
//this debug line works only in the emulator
//iEikonEnv->InfoMsg(_L("start"));
 
 
//iEngine->StartGame();
}
}


Postconditions

The menu open and close events has been caught and the pause state has been toggled accordingly.

86 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×