Enabling middle softkey labelling

To enable your application to use the MSK feature:

  1. Control the MSK visibility

    MSK visibility is controlled by Avkon’s CenRep key KaknMiddleSoftkeyEnabled. This key does NOT control the MSK feature – it is only meant for enabling or disabling MSK visibility (in portrait mode; in landscape modes MSK is never displayed). The following code can be used for checking MSK visiblity in the platform:

    #include <centralrepository.h>
    #include <avkoninternalcrkeys.h>  // KAknMiddleSoftkeyEnabled
    
        TInt MSKenabled( 0 );
        CRepository* cenRep = NULL;
        TRAPD( err, cenRep = CRepository::NewL( KCRUidAvkon ) );
        if ( !err )
            {
            err = cenRep->Get( KAknMiddleSoftkeyEnabled, MSKenabled );
            delete cenRep;
            }
  2. Enable the MSK feature

    The MSK feature is application-specific and the application must enable MSK by setting EAknEnableMSK flag in the BaseConstructL method of CAknViewAppUi or CAknAppUi:

    void CAknMyAppUi::ConstructL()
        {
        // MSK disabled
        BaseConstructL( EAknEnableSkin );
    
        // MSK enabled
        BaseConstructL( EAknEnableSkin | EAknEnableMSK );
    

    The application-specific MSK state can be queried by using:

    EXPORT_C TBool AknLayoutUtils::MSKEnabled()

  3. Define MSK key events

    Once an application enables MSK use, no EKeyOk key events are generated to it any longer. Instead the application will get a softkey command id – either from the MSK (if defined) or from the left softkey.

    If an application defines the MSK (or any softkey) with the EaknSoftkeyForwardKeyEvent command id, EKeyOk is forwarded from softkeys to the application and no softkey command is generated.

    EKeyOk is forwarded to the next component in the control stack like it is normally done in the OfferKeyEventL when EKeyWasNotConsumed is returned. In some cases this component can be an underlying CBA, which in turn handles a key event before the application will get it.