Nokia N97 SDK
Example Applications Guide

Pop-up field Example

1. About this Example
2. Architecture
3. Design and Implementation


1. About this Example

This tutorial explains how to use pop-up fields in Avkon applications. A pop-up field is used to show list items that end-users can select an item from. For example, end-users can select a setting from the setting list of a mobile phone.

The pop-up field example application helps you to understand the following:

The following UML diagram shows key classes of the pop-up field example application.

image_popfield001.gif


1.1 Prerequisites

An understanding of the following topics is important for using the pop-up field control:


2. Architecture

This example makes use of the standard Symbian OS application framework, comprising the Application, Document, UI, View and Container classes.

3. Design and Implementation

A pop-up field uses CAknFormGraphcStyleListBox to display a list. The example application uses pop-up field calling methods that are provided by CAknPopupField.

In the example application, a pop-up field is displayed using CAknExPopFieldBaseDialog that is an inherited class of CAknForm. By implementing this code, the pop-up field can be handled as though it is a control that is displayed on a dialog.

3.1 Resource definition of a dialog that is inherited from CAknForm

The following shows resource definition for using a pop-up field in the example application:

Example 1: Resource definition of a dialog (inherited from Form class) that uses a pop-up field.

 RESOURCE DIALOG r_aknexpopfield_two_text_field_dialog
   {
   flags = EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect |
           EEikDialogFlagNoTitleBar | EEikDialogFlagButtonsRight |
           EEikDialogFlagCbaButtons | EEikDialogFlagNoBorder;
   buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
   form = r_aknexpopfield_two_text_field_form;
   }

Note: Unlike standard dialog definition, the form field is used to define a dialog in this example.

Example 2: Contents resource definition of a dialog (inherited from Form class) that uses a pop-up field.

 RESOURCE FORM r_aknexpopfield_two_text_field_form
   {
   items =
     {
     DLG_LINE
       {
       type = EAknCtPopupField;
       prompt = qtn_aknexpopfield_label_pop01;
       id = EAknExPopFieldDlgCtrlIdPop01;
       itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
       control = POPUP_FIELD
         {
         width = AKNEXPOPFIELD_TEXT_WIDTH;
         other = qtn_aknexpopfield_list_other;
         };
       tooltip = qtn_aknexpopfield_hint_text;
       },
     DLG_LINE
       {
       type = EAknCtPopupField;
       prompt = qtn_aknexpopfield_label_pop02;
       id = EAknExPopFieldDlgCtrlIdPop02;
       itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
       control = POPUP_FIELD
         {
         width = AKNEXPOPFIELD_TEXT_WIDTH;
         other = qtn_aknexpopfield_list_other;
         };
       tooltip = qtn_aknexpopfield_hint_text;
       }
     };
   }

Note: The control type EAknCtPopupField is used to handle the pop-up field.

The following shows the POPUP_FIELD resource structure:

 STRUCT POPUP_FIELD
   {
   WORD flags=0;
   WORD width=0;
   LTEXT other="";
   LLINK emptynote = 0;
   LTEXT empty="";
   }

3.2 Instantiating and displaying a dialog object inherited from CAknForm

The following describes how an object is instantiated from the resource data defined above.

Example 3: Instantiation of a dialog object inherited from Form that uses a pop-up field.

 CAknExPopFieldAttribSetDialog* dlg = CAknExPopFieldAttribSetDialog::NewLC();
 CleanupStack::Pop();
 dlg->ExecuteLD( aResourceId );

image_popfield009.gif

3.3 Initialising the pop-up field

An array that defines pop-up field items to be selected is set to each class in following funtions:

In each of these functions, an array for selection items is set as follows:

 CAknPopupField * popup;
 ....
 popup->SetQueryValueL();

© Nokia 2009

Back to top