UIQ Technology
Symbian OS Library

UIQ 3.1 SDK        UIQ developer portal

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



UIQ Controls - Menu Popout


1. Introduction

This guide explains the UIQ control Menu Popout (CQikMenuPopout). The Menu Popout allows you to display a Menu Pane (CEikMenuPane) at an arbitrary position. It is normally used to display a menu pane in response to the selection of an on-screen item. In UI configurations with touch screens (EQikTouchScreenYes) you might display it at the position where the user taps with the pen. When selecting an item via softkeys, you might want the menu to be displayed above the selected item or as a menu pane just above the softkey buttons.

Menu Popout displayed when tapping on an...

Menu Popout displayed when tapping on an item

Menu Popout displayed when selecting an...

Menu Popout displayed when selecting an item via softkeys

The pictures above show typical usage of the Menu Popout.

The following functionality can be used by the application developer:


1.1 Further Reference

See the API documentation for the Menu Popout (CQikMenuPopout).

[Top]


2. Architecture

Menu Popout inherits from CBase and owns a CEikMenuPane.

High level architecture of Menu Popout

High level architecture of Menu Popout

[Top]


3. Using the Control

This section explains how the control is constructed, used and destroyed. Source code examples are used and explained to illustrate how the Menu Popout control is used.


3.1 Include and Identification

Use the following #include directive:

#include <QikMenuPopout.h>

Use the following LIBRARY directive in the project's mmp-file:

LIBRARY qikcore.lib


3.2 Resource Structure

You can construct the Menu Popout with commands specified in a QIK_COMMAND_LIST in the applications resource file; the resource name is referenced from code when it is to be created:

RESOURCE QIK_COMMAND_LIST r_menupopout_commands
  {
  items=
    {
    QIK_COMMAND
      {
      id = ECmdMenuPopoutCmd1;
      type=EQikCommandTypeScreen;
      text = "First Menu Popout item";
      },
    QIK_COMMAND
      {
      id = ECmdMenuPopoutCmd2;
      type=EQikCommandTypeScreen;
      text = "Second Menu Popout item";
      }
    };
  }


3.3 Construction and Launch

This section discusses the two ways of constructing and launching the control. The Menu Popout is constructed and launched from code; however, the commands can be added from code or read from a resource file.


3.3.2 Construction from C++ Code Using Commands from a Resource File

The example below describes how you can construct a Menu Popout with data from a resource file with your own C++ code.

In your constructor, create the Menu Popout:

iMenuPopout = CQikMenuPopout::NewL(*iEikonEnv, *this);

To finish creation and launch the Menu Popout below and to the right of where the pen is tapped:

void TestApp::HandlePointerEventL(const TPointerEvent& aPointerEvent)
  {
  switch(aPointerEvent.iType)
    {
    case TPointerEvent::EButton1Up:
      TPoint position(aPointerEvent.iPosition);
      position += iEikonEnv->EikAppUi()->ClientRect().iTl;
      iMenuPopout->SetCommandListL(R_MENUPOPOUT_COMMANDS);
      iMenuPopout->DisplayL(position, EPopupTargetTopLeft);
      break;

    default:
      break;        
    }
  }

The positioning of the Menu Popout is absolute. As the position of the pointer event is relative to the client rect, we need to add these two together to get the position for the Menu Popout.


3.3.3 Construction Solely from C++ Code

The example below describes how to construct a Menu Popout when the commands to display are obtained by other means than the application resource file.

For this example, it is assumed that your class has an array of commands to be added to the Menu Popout:

RPointerArray<CQikCommand> iCommands;

In the constructor you create the Menu Popout:

iMenuPopout = CQikMenuPopout::NewL(*iEikonEnv, *this);

If you are re-using the Menu Popout, that is, using it with different commands at different times, you should reset it before use:

iMenuPopout->ResetL();

Then, when you are ready to add commands and display it:

count = iCommands.Count();
for(TInt i=0; i < count; i++)
  {
  iMenuPopout->AddCommandL(*iCommands[i]);
  }

TPoint position = PositionRelativeToScreen();
position.iY += Size().iHeight;
TRAP_IGNORE(iMenuPopout->DisplayL(position, EPopupTargetBottomLeft, ETrue));


3.4 Using the Menu Popout

This section covers the most common functions used for interacting with the control.

3.4.1 How to be notified when a selection is made

In order to be notified when a command is selected you need to implement HandleCommandL.

void TestApp::HandleCommandL(CQikCommand& aCommand)
  {
  aCommand->ExecuteL();
  }

3.4.2 How to Get the CEikMenuPane

The Menu Popout uses a CEikMenuPane and it is possible to get a pointer to it for direct manipulation. Note: Calling ResetL() will invalidate this pointer!

CEikMenuPane* menuPane;
menuPane = iMenuPopout->MenuPane();


3.5. Destruction

Destroying the control is just a matter of invoking operator delete on the Menu Popout object.

[Top]


4. Subclassing

Subclassing Menu Popout is not recommended.