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.

Archived:Adding menu items dynamically 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
Compatibility
Platform(s): S60 1st Edition
S60 2nd Edition
S60 3rd Edition
Series 80 2nd Edition
S60 3rd Edition (initial release)
S60 2nd Edition (initial release)
S60 1st Edition
Article
Created: User:Technical writer 2 (04 Jul 2007)
Last edited: hamishwillee (14 Jun 2012)

Overview

Adding menu items dynamically

Description

Items can be added to the menu dynamically, without making any changes to the resource file.

Solution

First, use an 'empty' menu definition in the application resource file:
    #include <eikon.rh>
    #include <avkon.rh>
    #include <avkon.rsg>
    #include "MyApp.hrh"
    RESOURCE RSS_SIGNATURE
        {
        }
    RESOURCE TBUF r_default_document_name
        {
        buf="";
        }
    RESOURCE EIK_APP_INFO
        {
        menubar = r_myapp_menubar;
        cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
        }
    RESOURCE MENU_BAR r_myapp_menubar
        {
        titles =
            {
            MENU_TITLE
                {
                menu_pane = r_myapp_menu;
                }
            };
        }
    RESOURCE MENU_PANE r_myapp_menu
        {
        items =
            {
            // Empty implementation of menu
            };
        }
Then, override MEikMenuObserver::DynInitMenuPaneL() in the application UI class:
    void CMyAppUi::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
        {
        if( aResourceId == R_MYAPP_MENU )
            {
            CEikMenuPaneItem::SData itemData;
            itemData.iText = _L("New menu item");  // Label text for the menu item
            itemData.iCommandId = ECmdYourMenu;    // Command ID for the menu item
            itemData.iFlags = 0;
            itemData.iCascadeId = 0;
            aMenuPane->AddMenuItemL( itemData );
            }
        }
Note that there is no need to call DynInitMenuPaneL() directly as it will be called by the framework once the menu softkey is pressed.

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

×