UIQ Technology
Symbian OS Library

UIQ 3.1 SDK        UIQ developer portal

[Index] [Spacer] [Previous] [Next]



How to Use Menus Dynamically

An application can initialize menu items by implementing DynInitMenuPaneL() in the CQikAppUi-derived class. The framework calls this function immediately before a menu pane is activated and displayed on the screen. Typically, DynInitOrDeleteCommandL() reads application data and initialize menu items accordingly.

UIQ applications may use more than one menu and change them dynamically when switching views. You can change the menu bar completely using CEikMenuBar::ChangeMenuBarL.


Dimming a menu option

To dim a menu item, use CEikMenuPane::SetItemDimmed() with ETrue as a parameter. To remove dimming from a menu item, use the same function, with EFalse as a parameter.

Menu items can be dimmed by default using the EEikMenuItemDimmed flag in the resource file.

[Top]


Changing menu item text

To set a menu item text dynamically, use CEikMenuPane::SetItemTextL(). This has two forms: one takes a descriptor containing the text to display, the other takes a resource ID, which should specify a text resource containing the text to display. This allows the menu item text to be specified in the resource file.

[Top]


Setting the state of check boxes and radio buttons

Each check box or radio button can have one of two states, EEikMenuItemSymbolOn or EEikMenuItemSymbolIndeterminate.

The framework displays a symbol to the left of the text in an item with a state of EEikMenuItemSymbolOn. It is up to the application, however, to set the states of the buttons as required, according to the state of application data. It should do this in DynInitOrDeleteCommandL().

The default state of all items before a menu pane is displayed is EEikMenuItemSymbolIndeterminate. The application should set the state of any items that require a state of EEikMenuItemSymbolOn using CEikMenuPane::SetItemButtonState().

Note that the framework does not enforce the rule that only one radio button in a group can have a state of EEikMenuItemSymbolOn. The application should therefore enforce this.

When the user selects a check box or radio button in a menu, the framework updates the symbols to reflect the user's selection, before the menu disappears. When the menu is activated again, however, the item states must be set by the application.

[Top]


Adding a menu item dynamically

To add a menu item dynamically to a menu pane, use CEikMenuPane::AddMenuItemL().

The following example demonstrates how to add a close option. In the example, aMenuPane is a CEikMenuPane* passed in when DynInitMenuPaneL() is called.

// declare structure to hold details of menu item to add CEikMenuPaneItem::SData itemData;
// set the command for the item and any extra flags
itemData.iText=_L("Close (debug)");
itemData.iCommandId=EEikCmdExit;
itemData.iFlags=0;
itemData.iCascadeId=0;
// add the item
aMenuPane->AddMenuItemL(itemData);

The close option allows you to close down your application, letting the framework check for memory and resource leaks. Note that this should be provided for debugging purposes only.