Title Pane触摸监测API
文章信息
Contents |
简介
标题触摸监测API允许一个程序监测用户对标题的触控。如利用这个API可以当用户按住标题栏时恢复程序缺省视图。这个需要完成MAknTitlePaneObserver的HandleTitlePaneEventL()方法,即可对标题触控响应
MMP文件
CAPABILITY none
LIBRARY avkon.lib
头文件
#include <akntitlepaneobserver.h>
class CSampleAppUi : public CAknAppUi, public MAknTitlePaneObserver
{
...
private:
/**
* From MAknTitlePaneObserver
*/
void HandleTitlePaneEventL(TInt aEventID);
...
};
源文件
#include <eikspane.h>
#include <akntitle.h>
// AppUi second-phase constructor
void CSampleAppUi::ConstructL()
{
...
// Call CAknAppUi::StatusPane() which returns CEikStatusPane*
CEikStatusPane* statusPane = StatusPane();
if (statusPane)
{
// Title pane UID
TUid titlePaneUid;
titlePaneUid.iUid = EEikStatusPaneUidTitle;
// Get pointer to CAknTitlePane object
CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(titlePaneUid);
// Set this AppUi object as the observer of the title pane
titlePane->SetTitlePaneObserver(this);
}
...
}
// Implementation of the observer interface
void CSampleAppUi::HandleTitlePaneEventL(TInt aEventID)
{
// Although at the moment EAknTitlePaneTapped
// is the only one value in the TAknTitlePaneEvents enumeration,
// we should consider that later that enumeration could be extended
if (aEventID == EAknTitlePaneTapped)
{
// Custom action on title pane tapping event
}
else
{
// No implementation's required at the moment
}
}
后记
标题栏的触控将被监控到


(no comments yet)