Symbian3/SDK/Source/GUID-D0F6E95B-B35A-4EA1-8CC3-D86D1E0E6DD3.dita
changeset 13 48780e181b38
parent 8 ae94777fff8f
--- a/Symbian3/SDK/Source/GUID-D0F6E95B-B35A-4EA1-8CC3-D86D1E0E6DD3.dita	Fri Jul 16 17:23:46 2010 +0100
+++ b/Symbian3/SDK/Source/GUID-D0F6E95B-B35A-4EA1-8CC3-D86D1E0E6DD3.dita	Tue Jul 20 12:00:49 2010 +0100
@@ -21,60 +21,52 @@
 resource that defines the menu items:</p>
 <note><p>The menu is constructed only once: when <codeph>HandlePointerEventL</codeph> runs
 for the first time. Later the already constructed menu is shown again.</p></note>
-<p>The following code snippets explain how to create and display Stylus pop-up
-menu:<ul>
-<li><p><b>Creating directly:</b></p><codeblock xml:space="preserve">// member variable point to the stylus Popup menu
-CAknStylusPopUpMenu * iPopupMenu ;
-_LIT(KItem1, "Item 1");
-_LIT(KItem2, "Item 2");
-_LIT(KItem3, "Item 3");
-_LIT(KItem4, "Item 4");
-enum StylusPopupMenuCommand
-	{
-	StylusMenuCommand1 = 0 ,
-	StylusMenuCommand2,
-	StylusMenuCommand3,
-	StylusMenuCommand4
-	};
-// create object , “this” is a object implement the interface 
-// MEikMenuObserver
-iPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint( 0 , 0 ) );
-// add menu item
-iPopupMenu-&gt;AddMenuItemL( KItem1 , StylusMenuCommand1 );
-iPopupMenu-&gt;AddMenuItemL( KItem2 , StylusMenuCommand2 );
-iPopupMenu-&gt;AddMenuItemL( KItem3 , StylusMenuCommand3 );
-iPopupMenu-&gt;AddMenuItemL( KItem4 , StylusMenuCommand4 );
-</codeblock></li>
-<li><p><b>Creating through resource file:</b></p><codeblock xml:space="preserve">RESOURCE STYLUS_POPUP_MENU r_stylus_popup_menu
-	{
-		items =
-		{
-			STYLUS_POPUP_MENU_ITEM
-				{
-					txt = "Menu Item 1";
-					command = EStylusPopupCommand1;				},
-			STYLUS_POPUP_MENU_ITEM
-				{
-					txt = "Menu Item 2";
-					command = EStylusPopupCommand2;				},
-			STYLUS_POPUP_MENU_ITEM
-				{
-					txt = "Menu Item 3";
-					command = EStylusPopupCommand3;
-				}
-		};
-	}
-// create object
-iPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint( 0 , 0 ) );
-{
-	TResourceReader reader;
-	iCoeEnv-&gt;CreateResourceReaderLC( 
-                       reader , 
-                       R_STYLUS_POPUP_MENU );
-	iPopupMenu-&gt;ConstructFromResourceL( reader );
-		// destroy reader
-	CleanupStack::PopAndDestroy();
-}
-</codeblock></li>
-</ul></p>
+<codeblock xml:space="preserve">void CMyAppView::HandlePointerEventL
+    ( const TPointerEvent&amp; aPointerEvent )
+    {
+    if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
+        {
+        if ( !iMenu )
+            {
+            iMenu = CAknStylusPopUpMenu::NewL( 
+                    iMenuObserver, 
+                    aPointerEvent.iParentPosition, 
+                    NULL );
+            TInt resourceReaderId = 0;
+            resourceReaderId = R_MYAPP_STYLUS_MENU;
+            TResourceReader reader;
+            iCoeEnv-&gt;CreateResourceReaderLC( 
+                    reader, resourceReaderId );
+            iMenu-&gt;ConstructFromResourceL( reader );
+            CleanupStack::PopAndDestroy(); // reader
+            }
+        iMenu-&gt;SetPosition( aPointerEvent.iParentPosition );
+        iMenu-&gt;ShowMenu();
+        }
+    // Forward event to base class too.
+    CCoeControl::HandlePointerEventL( aPointerEvent );
+    }
+
+RESOURCE STYLUS_POPUP_MENU r_myapp_stylus_menu
+    {
+    items =
+        {
+        STYLUS_POPUP_MENU_ITEM 
+            {
+            txt = "Stylus Popup Menu Item 1"; 
+            command = EMyAppMenuItemCmd1;
+            },
+        STYLUS_POPUP_MENU_ITEM 
+            {
+            txt = "Stylus Popup Menu Item 2"; 
+            command = EMyAppMenuItemCmd2; 
+            },
+        STYLUS_POPUP_MENU_ITEM 
+            { 
+            txt = "Stylus Popup Menu Item 3"; 
+            command = EMyAppMenuItemCmd3; 
+            }
+        };
+    }
+</codeblock>
 </conbody></concept>
\ No newline at end of file