Archived:Retrieving text for softkey labels using Symbian C++
Article Metadata
Compatibility
S60 3rd Edition, FP1
Article
Overview
Retrieving text for softkey labels
Description
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.
Solution
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();
}
}
}
Notes:
- 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.


(no comments yet)