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. Thanks for all your past and future contributions.

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

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Tested with
Devices(s): Nokia 6220 Classic
Platform(s): S60 3rd Edition
Platform Security
Signing Required: Self-Signed
Keywords: MEikMenuObserver, MEikMenuObserver::SetEmphasis()
Created: aknyman (02 Oct 2008)
Last edited: lpvalente (23 Sep 2014)



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__
#include <aknappui.h>
class CTestAAppView;
//class CGameEngine;
* 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);
// 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)
void CTestAAppUi::SetUiPauseState(TBool aEmphasis)
//pause game if menu is activated
if(aEmphasis /*&& !iEngine->IsStopped()*/)
//this debug line works only in the emulator
//this debug line works only in the emulator


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

This page was last modified on 23 September 2014, at 19:50.
46 page views in the last 30 days.