×
Namespaces

Variants
Actions
Revision as of 02:13, 15 June 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

捕捉菜单打开和关闭事件

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

测试基于
设备:: Nokia 6220 Classic

兼容于
平台: S60 3rd Edition

平台安全性
需要的签名: Self-Signed

文章
关键词: MEikMenuObserver, MEikMenuObserver::SetEmphasis()
翻译:
hoolee
最后由 hamishwillee 在 15 Jun 2012 编辑
  • 详细描述

这个代码片段演示了如何在CAknAppUi派生类中捕捉菜单打开和关闭事件。这些事件可通过MEikEemuObserver中派生的SetEmphasis()方法来捕捉。如当一个游戏打开菜单而需要暂停时,就需要捕捉这样的事件。

此代码可以通过自签名来完成。

  • MMP文件

需要下列链接库

LIBRARY     avkon.lib   //Avkon resources
  • 头文件
#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__


  • 源文件
#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();
}
}
This page was last modified on 15 June 2012, at 02:13.
155 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.

×