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.

如何获取功能键上的文字

From Wiki
Jump to: navigation, search
Article Metadata

文章
huwell 在 03 Jul 2007 创建
最后由 hamishwillee 在 15 Dec 2011 编辑
  • 设备, 软件 版本:

S60 3rd Edition S60 3rd Edition, FP1


  • 详细描述:

描述

下列代码演示了如何获取当前control pane(CBA)上左、中、右功能键的文字。

我们可以通过CCoeControl::ComponentControl()获取每个功能键的label(CEikLabel),它是功能键上第一个控件。


解决方案

    CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();     
 
if( cba )
 
{
 
MEikButtonGroup* buttonGroup = cba->ButtonGroup();
 
for( TInt pos = 0; pos < 3; pos++ )
 
{
 
TInt cmdId = buttonGroup->CommandId( pos );
 
CCoeControl* button = buttonGroup->GroupControlById( cmdId );
 
if( button && buttonGroup->IsCommandVisible( cmdId ))
 
{
 
CEikLabel* label = static_cast<CEikLabel*>( button->ComponentControl(0) );
 
const TDesC* txt = label->Text();
 
}
 
}
 
}


注意

1、上述代码总是返回完整的lable text,即使显示在屏幕上的label是缩短过文字的。

2、CEikCommandButton类中提供了Label()方法以完成该项功能,但目前CBA的实现并没支持该类。CEikButtonGroupContainer::CommandButtonOrNull()总是会返回NULL。

This page was last modified on 15 December 2011, at 09:59.
76 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.

×