|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-D0F6E95B-B35A-4EA1-8CC3-D86D1E0E6DD3" xml:lang="en"><title>Creating |
|
13 stylus pop-up menu</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>Construct the menu using the method <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknStylusPopUpMenu.html#9dda70f72d42d0877cbbf9ca299649af" format="application/java-archive"><codeph>NewL()</codeph></xref>in the class <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknStylusPopUpMenu.html" format="application/java-archive"><codeph>CAknStylusPopUpMenu</codeph></xref>.</p> |
|
15 <note> <p>The last parameter in the constructor is a pointer to the preview |
|
16 pop-up from which the stylus pop-up menu is launched. If you are not constructing |
|
17 a pop-up menu for a preview pop-up, set the parameter as <codeph>NULL</codeph>.</p></note> |
|
18 <p>To construct the menu from a resource, use the method <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknStylusPopUpMenu.html#75cd95c35a6ed4734b93713596bb51d5" format="application/java-archive"><codeph>CAknStylusPopUpMenu::ConstructFromResourceL()</codeph></xref>.</p> |
|
19 <p>The following example illustrates a stylus pop-up menu opened in the location |
|
20 (not a preview pop-up) where the user taps with the stylus as well as the |
|
21 resource that defines the menu items:</p> |
|
22 <note><p>The menu is constructed only once: when <codeph>HandlePointerEventL</codeph> runs |
|
23 for the first time. Later the already constructed menu is shown again.</p></note> |
|
24 <codeblock xml:space="preserve">void CMyAppView::HandlePointerEventL |
|
25 ( const TPointerEvent& aPointerEvent ) |
|
26 { |
|
27 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
28 { |
|
29 if ( !iMenu ) |
|
30 { |
|
31 iMenu = CAknStylusPopUpMenu::NewL( |
|
32 iMenuObserver, |
|
33 aPointerEvent.iParentPosition, |
|
34 NULL ); |
|
35 TInt resourceReaderId = 0; |
|
36 resourceReaderId = R_MYAPP_STYLUS_MENU; |
|
37 TResourceReader reader; |
|
38 iCoeEnv->CreateResourceReaderLC( |
|
39 reader, resourceReaderId ); |
|
40 iMenu->ConstructFromResourceL( reader ); |
|
41 CleanupStack::PopAndDestroy(); // reader |
|
42 } |
|
43 iMenu->SetPosition( aPointerEvent.iParentPosition ); |
|
44 iMenu->ShowMenu(); |
|
45 } |
|
46 // Forward event to base class too. |
|
47 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
48 } |
|
49 |
|
50 RESOURCE STYLUS_POPUP_MENU r_myapp_stylus_menu |
|
51 { |
|
52 items = |
|
53 { |
|
54 STYLUS_POPUP_MENU_ITEM |
|
55 { |
|
56 txt = "Stylus Popup Menu Item 1"; |
|
57 command = EMyAppMenuItemCmd1; |
|
58 }, |
|
59 STYLUS_POPUP_MENU_ITEM |
|
60 { |
|
61 txt = "Stylus Popup Menu Item 2"; |
|
62 command = EMyAppMenuItemCmd2; |
|
63 }, |
|
64 STYLUS_POPUP_MENU_ITEM |
|
65 { |
|
66 txt = "Stylus Popup Menu Item 3"; |
|
67 command = EMyAppMenuItemCmd3; |
|
68 } |
|
69 }; |
|
70 } |
|
71 </codeblock> |
|
72 </conbody></concept> |