diff -r 42e9659b68d1 -r 41890dfa56f5 org.symbian.wrttools.doc.WRTKit/html/WRTKit_Using_buttons-GUID-8b14cec9-92cc-4bde-83c2-ad0a30a84942.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.wrttools.doc.WRTKit/html/WRTKit_Using_buttons-GUID-8b14cec9-92cc-4bde-83c2-ad0a30a84942.html Thu Mar 04 15:42:37 2010 -0800 @@ -0,0 +1,92 @@ + + +
+ + + + + + + + + + ++ + You can let users trigger actions by placing a FormButton or + NavigationButton control in a view. Use FormButtons for actions that + start some process and NavigationButton controls for situations + where pressing the button should take the viewer to another view. +
+ + + ++ + You can find out when a button has been pressed by registering a + callback function as an event listener to the button. The event type + for button presses is "ActionPerformed". You can use whatever name + you like for the callback function. The function is passed the event + object as an argument. A typical callback function looks like this: +
+ ++ +// Callback function for button presses. +function buttonPressed(event) { + // implement what happens when the button is pressed here +} ++ +
+ + Creating a button, registering the event listener and adding the + button to a view is demonstrated below. The example creates a + FormButton: +
+ ++ +// create button +var button = new FormButton("button1", "Press me!"); +button.addEventListener("ActionPerformed", buttonPressed); +exampleView.addControl(button); ++ +
+ + Note that the example assumes that a view has already been created + and that the "exampleView" variable refers to that view. "button1" + is a unique identifier for the button that allows it to be identified + for example if several different controls are using a shared event + listener function. The event listener function could examine the event + object and check the identifier of the source control for the event. +
+ +