# Actions

Widgets can let users trigger actions in many ways. One way is by inserting menu items in the Options menu, using the menu object that the S60 Web Runtime defines. Another way is to use links that call JavaScript functions. Such links could for example be included as part of content in a ContentPanel control. Links belong more to web pages than widgets or applications, however, and are not recommended except in cases when they result in a web URL being opened up in a web browser (i.e. using the widget.openURL() method).

The third way is to use one of the WRTKit action controls: FormButton and NavigationButton. Both controls are very similar in usage but differ greatly in presentation and intended use. The FormButton control is meant to be used in situations where pressing the button would result in some kind of process taking place, e.g. settings being saved. The NavigationButton control is intended for moving between views inside the widget, or other similar type of actions. FormButton controls look similar to buttons in a PC application or "Submit"- buttons on a web page. NavigatationButton controls don't really have a counterpart in the PC application domain, but is common in mobile device application that have large user interfaces that are split into several views.

Figure 1. NavigationButton controls

In an email widget, NavigationButton controls could be used so that there would be a "Folders"-view where each folder (e.g. Inbox, Sent, Trash, etc.) would have a corresponding NavigationButton. Clicking on the button for a folder would open up that folder in a new view. FormButton controls could be used for example in a view that lets users write new emails to trigger sending of the written email. A FormButton in a view like that could have "Send" as the button text.

Figure 2. FormButton controls

The FormButton and NavigationButton controls fire events with the event type "ActionPerformed" whenever a user presses the button. The event can be turned into a function call to a callback function of the developer's choice by registering the function to the control for the "ActionPerformed" event type. This is done using the addEventListener() method that all controls inherit from the UIElement base class.

Parent topic: Developing widgets using the WRTKit