×
Namespaces

Variants
Actions

S60平台处理按键的方法

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

兼容于
平台:
Symbian

文章
r60600 在 07 Jan 2008 创建
最后由 hamishwillee 在 08 May 2013 编辑

S60平台应用往往需要直接处理按键,主要有两种方法:


一.继承自CAknAppUi的实例使用HandleKeyEventL

TKeyResponse CxxxAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) 
{
if (aType==EEventKeyDown && (aKeyEvent.iScanCode == EStdKeyDevice0 || aKeyEvent.iScanCode == EStdKeyDevice1 )) 
{
//按左右功能键的处理
}
else
{
//按非左右功能键的处理 
}
return( EKeyWasNotConsumed );
}


二.继承自CCoeControl的实例使用OfferKeyEventL

TKeyResponse CxxxContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
if ( aType == EEventKey )
{
if ( aKeyEvent.iScanCode == EStdKeyDevice0 )
{
//按左功能键的处理
return( EKeyWasNotConsumed );
}
if ( aKeyEvent.iScanCode == EStdKeyDevice1 )
{
//按右功能键的处理
return( EKeyWasNotConsumed );
}
}
return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
}
This page was last modified on 8 May 2013, at 03:03.
103 page views in the last 30 days.