org.symbian.wrttools.doc.WRTKit/html/WRTKit_Using_buttons-GUID-8b14cec9-92cc-4bde-83c2-ad0a30a84942.html
changeset 230 7848c135d915
parent 229 716254ccbcc0
child 231 611be8d22832
equal deleted inserted replaced
229:716254ccbcc0 230:7848c135d915
     1 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
     2 <html lang="en" xml:lang="en">
       
     3 <head>
       
     4 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
       
     5 <meta name="copyright" content="(C) Copyright 2005" />
       
     6 <meta name="DC.rights.owner" content="(C) Copyright 2005" />
       
     7 <meta content="concept" name="DC.Type" />
       
     8 <meta name="DC.Title" content="Using buttons" />
       
     9 <meta scheme="URI" name="DC.Relation" content="WRTKit_Common_WRTKit_tasks-GUID-24870895-4449-4307-9a54-7c90f7b3905e.html" />
       
    10 <meta content="XHTML" name="DC.Format" />
       
    11 <meta content="GUID-8B14CEC9-92CC-4BDE-83C2-AD0A30A84942" name="DC.Identifier" />
       
    12 <meta content="en" name="DC.Language" />
       
    13 <link href="commonltr.css" type="text/css" rel="stylesheet" />
       
    14 <title>
       
    15 Using buttons</title>
       
    16 </head>
       
    17 <body id="GUID-8B14CEC9-92CC-4BDE-83C2-AD0A30A84942"><a name="GUID-8B14CEC9-92CC-4BDE-83C2-AD0A30A84942"><!-- --></a>
       
    18 
       
    19 
       
    20 
       
    21     <h1 class="topictitle1">
       
    22 Using buttons</h1>
       
    23 
       
    24     <div>
       
    25 
       
    26         <p>
       
    27 
       
    28             You can let users trigger actions by placing a FormButton or 
       
    29             NavigationButton control in a view. Use FormButtons for actions that 
       
    30             start some process and NavigationButton controls for situations 
       
    31             where pressing the button should take the viewer to another view.
       
    32         </p>
       
    33 
       
    34         <div class="fignone" id="GUID-8B14CEC9-92CC-4BDE-83C2-AD0A30A84942__GUID-B008BB2B-C5B2-446D-BCED-2824528CF7CC"><a name="GUID-8B14CEC9-92CC-4BDE-83C2-AD0A30A84942__GUID-B008BB2B-C5B2-446D-BCED-2824528CF7CC"><!-- --></a><span class="figcap">Figure 1. 
       
    35 FormButton controls</span>
       
    36 
       
    37             
       
    38             <br /><img src="FormButton_Controls_Screenshot_1.png" /><br />
       
    39         </div>
       
    40 
       
    41         <p>
       
    42 
       
    43             You can find out when a button has been pressed by registering a 
       
    44             callback function as an event listener to the button. The event type 
       
    45             for button presses is "ActionPerformed". You can use whatever name 
       
    46             you like for the callback function. The function is passed the event 
       
    47             object as an argument. A typical callback function looks like this:
       
    48         </p>
       
    49 
       
    50 <pre>
       
    51 
       
    52 // Callback function for button presses.
       
    53 function buttonPressed(event) {
       
    54     // implement what happens when the button is pressed here
       
    55 }
       
    56 </pre>
       
    57 
       
    58         <p>
       
    59 
       
    60             Creating a button, registering the event listener and adding the 
       
    61             button to a view is demonstrated below. The example creates a 
       
    62             FormButton:
       
    63         </p>
       
    64 
       
    65 <pre>
       
    66 
       
    67 // create button
       
    68 var button = new FormButton("button1", "Press me!");
       
    69 button.addEventListener("ActionPerformed", buttonPressed);
       
    70 exampleView.addControl(button);
       
    71 </pre>
       
    72 
       
    73         <p>
       
    74 
       
    75             Note that the example assumes that a view has already been created 
       
    76             and that the "exampleView" variable refers to that view. "button1" 
       
    77             is a unique identifier for the button that allows it to be identified
       
    78             for example if several different controls are using a shared event
       
    79             listener function. The event listener function could examine the event
       
    80             object and check the identifier of the source control for the event.
       
    81         </p>
       
    82 
       
    83     </div>
       
    84 
       
    85 <div>
       
    86 <div class="familylinks">
       
    87 <div class="parentlink"><strong>Parent topic:</strong> <a href="WRTKit_Common_WRTKit_tasks-GUID-24870895-4449-4307-9a54-7c90f7b3905e.html">Common WRTKit tasks</a></div>
       
    88 </div>
       
    89 </div>
       
    90 
       
    91 </body>
       
    92 </html>