Symbian3/SDK/Source/GUID-405F7AB8-0F0E-4171-95E6-3524D76917DE.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 0 89d6a7a84779
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-405F7AB8-0F0E-4171-95E6-3524D76917DE" xml:lang="en"><title>Handling stylus pop-up menu events and commands</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>At the construction phase, <codeph>CAknStylusPopUpMenu</codeph> is given a <codeph>MEikMenuObserver</codeph> object, which is usually
a pointer to the application’s UI (<xref href="GUID-77329067-34D9-3698-B764-294535E660EB.dita"><apiname>CAknAppUi</apiname></xref>) or
another class that implements the interface. The stylus pop up menu
will grab the stylus event when one of its items is tapped on and
it will then report the item’s command ID to the menu observer. It
is then up to the application to handle the command in the implementation
of <xref href="GUID-CDB32ABA-F567-395D-9A00-2AC518BD5F3B.dita#GUID-CDB32ABA-F567-395D-9A00-2AC518BD5F3B/GUID-5A200511-9E99-3E2F-8E1B-B4A724BD2704"><apiname>MEikMenuObserver::HandleCommandL()</apiname></xref>. </p>
<p>When an item is  tapped, the menu calls its observer's (<codeph>iMenuObserver</codeph>) <codeph>ProcessCommandL()</codeph> using:<codeblock xml:space="preserve">void ProcessCommandL(TInt aCommandId);</codeblock> where, <codeph>aCommandID</codeph> parameter is the command number recorded in 
the resource file. You can also add it using <codeph>AddMenuItemL()</codeph> function as shown in the following code snippet:<codeblock xml:space="preserve">void AddMenuItemL( const TDesC&amp; aItem, const TInt aCommandId );</codeblock></p>
<p>The following code snippet illustrates how to handle the command:<codeblock xml:space="preserve">switch( aCommandId )
		{
		case StylusMenuCommand1:
			break;
		case StylusMenuCommand2:
			break;
		case StylusMenuCommand3:
			break;
		case StylusMenuCommand4:
			break;
		case KErrCancel:
			break;
		default:
			break;
		}
</codeblock> </p>
<p>Typically the observer is application's AppUi. It is then the observer's
responsibility to handle the command appropriately. The observer is
informed with <codeph>KErrCancel</codeph> if the menu is closed without
making a selection.</p>
<p>Use the <xref href="GUID-FB7D03CC-6FE6-3B2E-997F-A220A92BF5E8.dita#GUID-FB7D03CC-6FE6-3B2E-997F-A220A92BF5E8/GUID-100C0AE9-D134-3409-8620-7343033DF5BA"><apiname>CAknStylusPopUpMenu::HandleControlEventL()</apiname></xref> method to handle events that occur when user selects a menu item.</p>
<codeblock xml:space="preserve"/>
</conbody></concept>