|
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-B57ECD51-85EF-50EA-B3EE-62A85CD9C382" xml:lang="en"><title>How |
|
13 to use a notifier to display a simple dialog, asynchronously</title><shortdesc>Provides code snippets to show you how to use a notifier to display |
|
14 a simple dialog asynchronously.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
15 <p>To display a simple dialog box:</p> |
|
16 <ul> |
|
17 <li id="GUID-9BB8982B-727E-57FB-951F-EEA8CA49D203"><p>construct an <codeph>RNotifier</codeph> object |
|
18 and then call its <codeph>Connect()</codeph> member function to create a session |
|
19 with the Notifier server.</p> </li> |
|
20 <li id="GUID-F6523ED3-4816-538B-86BB-576A05E47197"><p>call the <codeph>Notify()</codeph> member |
|
21 function of the <codeph>RNotifier</codeph>, passing descriptors containing |
|
22 the two lines of text to be displayed and the characters for the buttons. <codeph>Notify()</codeph> makes |
|
23 an asynchronous request to the notifier server.</p> </li> |
|
24 </ul> |
|
25 <p>When the user keys in one of the button characters, the requesting thread's <keyword>request |
|
26 semaphore</keyword> is signalled to indicate that the notifier request is |
|
27 complete. The <codeph>TRequestStatus</codeph> object supplied by the requesting |
|
28 thread is set to <codeph>KErrNone</codeph>.</p> |
|
29 <p>In addition, a <codeph>TInt</codeph>, passed by reference to <codeph>Notify()</codeph>, |
|
30 is set to 0 or 1 depending on whether the first or the second button is selected.</p> |
|
31 <p>The session is closed by calling the <codeph>Close()</codeph> member function |
|
32 of the <codeph>RNotifier</codeph>.</p> |
|
33 <p>The following code fragments demonstrate this:</p> |
|
34 <codeblock id="GUID-8FDAA342-A5C9-5D27-B3DE-8F62124BADA4" xml:space="preserve">{ |
|
35 _LIT(KTxtLine1,"First line"); |
|
36 _LIT(KTxtLine2,"Second line"); |
|
37 _LIT(KButt1,"a"); |
|
38 _LIT(KButt2,"b"); |
|
39 ... |
|
40 TInt whichbutton(-1); |
|
41 TRequestStatus stat; |
|
42 ... |
|
43 RNotifier notifier; |
|
44 ... |
|
45 notifier.Connect(); |
|
46 ... |
|
47 notifier.Notify(KTxtLine1,KTxtLine2,KButt1,KButt2,whichbutton,stat); |
|
48 ... |
|
49 // other code |
|
50 ... |
|
51 User::WaitForRequest(stat); |
|
52 ... |
|
53 if (whichbutton==0) |
|
54 { |
|
55 // first button selected |
|
56 } |
|
57 if (whichbutton==1) |
|
58 { |
|
59 // Second button selected |
|
60 } |
|
61 ... |
|
62 notifier.Close(); |
|
63 ... |
|
64 }</codeblock> |
|
65 <p>Note that the descriptor parameters passed to <codeph>Notify()</codeph> must |
|
66 remain in existence until the notify request completes; this may be some time |
|
67 after the call to <codeph>Notify()</codeph> itself.</p> |
|
68 </conbody></concept> |