Symbian3/SDK/Source/GUID-405F7AB8-0F0E-4171-95E6-3524D76917DE.dita
changeset 13 48780e181b38
parent 8 ae94777fff8f
equal deleted inserted replaced
12:80ef3a206772 13:48780e181b38
     7     Nokia Corporation - initial contribution.
     7     Nokia Corporation - initial contribution.
     8 Contributors: 
     8 Contributors: 
     9 -->
     9 -->
    10 <!DOCTYPE concept
    10 <!DOCTYPE concept
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    12 <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>
    12 <concept id="GUID-405F7AB8-0F0E-4171-95E6-3524D76917DE" xml:lang="en"><title>Handling
    13 <p>At the construction phase, <codeph>CAknStylusPopUpMenu</codeph> is given a <codeph>MEikMenuObserver</codeph> object, which is usually
    13 stylus pop-up menu events and commands</title><prolog><metadata><keywords/></metadata></prolog><conbody>
    14 a pointer to the application’s UI (<xref href="GUID-77329067-34D9-3698-B764-294535E660EB.dita"><apiname>CAknAppUi</apiname></xref>) or
    14 <p>At the construction phase, <codeph>CAknStylusPopUpMenu</codeph> is given
    15 another class that implements the interface. The stylus pop up menu
    15 a <codeph>MEikMenuObserver</codeph> object, which is usually a pointer to
    16 will grab the stylus event when one of its items is tapped on and
    16 the application’s UI (<xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknAppUi.html" format="application/java-archive"><codeph>CAknAppUi</codeph></xref>)
    17 it will then report the item’s command ID to the menu observer. It
    17 or another class that implements the interface. The stylus pop up menu will
    18 is then up to the application to handle the command in the implementation
    18 grab the stylus event when one of its items is tapped on and it will then
    19 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>
    19 report the item’s command ID to the menu observer. It is then up to the application
    20 <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 
    20 to handle the command in the implementation of <codeph>MEikMenuObserver::HandleCommandL()</codeph>. </p>
    21 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>
    21 <p>When an item is  tapped, the menu calls its observer's (iMenuObserver)
    22 <p>The following code snippet illustrates how to handle the command:<codeblock xml:space="preserve">switch( aCommandId )
    22 ProcessCommandL. Typically the observer is application's AppUi. It is then
    23 		{
    23 the observer's responsibility to handle the command appropriately. The observer
    24 		case StylusMenuCommand1:
    24 is informed with KErrCancel if the menu is closed without making a selection.</p>
    25 			break;
    25 <p><draft-comment time="2008-05-15T15:38" translate="no">Add sample code on event and command
    26 		case StylusMenuCommand2:
    26 handling here.</draft-comment></p>
    27 			break;
       
    28 		case StylusMenuCommand3:
       
    29 			break;
       
    30 		case StylusMenuCommand4:
       
    31 			break;
       
    32 		case KErrCancel:
       
    33 			break;
       
    34 		default:
       
    35 			break;
       
    36 		}
       
    37 </codeblock> </p>
       
    38 <p>Typically the observer is application's AppUi. It is then the observer's
       
    39 responsibility to handle the command appropriately. The observer is
       
    40 informed with <codeph>KErrCancel</codeph> if the menu is closed without
       
    41 making a selection.</p>
       
    42 <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>
       
    43 <codeblock xml:space="preserve"/>
       
    44 </conbody></concept>
    27 </conbody></concept>