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.

Archived:Retrieving text for softkey labels using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Platform(s): S60 3rd Edition
S60 3rd Edition, FP1
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Created: User:Technical writer 2 (04 Jun 2007)
Last edited: hamishwillee (14 Jun 2012)


Retrieving text for softkey labels


The following code example demonstrates how to read label texts currently displayed in the control pane (CBA) for left, middle (if in use), and right softkeys.
A label (CEikLabel) for each softkey can be retrieved with CCoeControl::ComponentControl(). The label is the first control owned by the softkey.


    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();
- The above code always returns the full label text, even if a shortened version of the label is displayed on screen.
- The CEikCommandButton class provides a Label() function for this purpose. However, this class is not supported by the current implementation of CBA; CEikButtonGroupContainer::CommandButtonOrNull() always returns NULL.

This page was last modified on 14 June 2012, at 07:37.
33 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.