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.

S60平台处理按键的方法

From 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 00:03.
188 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.

×