Buttons and Selectors

Buttons and selectors are the simplest Mojo widgets. Earlier in the chapter, you saw how to use a toggle button; all the other buttons and selectors work in a very similar way. In this section, we’ll work directly with the Button widget, adding one to the News application, and we’ll touch on the other widgets in this group: Toggle Button, Check Box, Radio Button, List Selector, and Slider.

Buttons

You can use simple HTML divs styled as button widgets; these will work quite well in many cases. Button widgets, can behave dynamically, for example, displaying a spinner to show activity. Figure 3-1 shows an example of the Button widget.

Buttons are the most basic UI element, bounding an action to a region. When a user pushes a button, the button can change state and then gracefully return to the previous state, much like a doorbell. You can create unstyled buttons, or you can style them as objects, and you can label them in some way with text or images. You can disable Mojo buttons, and you can configure them to show activity indicators.

A Button widget example

Figure 3-1. A Button widget example

Use an HTML button for initiating actions, but use a Button widget when you are combining an action initiation with an indicator, or for any asynchronous actions. As we did in Chapter 2 for switching scenes, declare HTML buttons in your view file using conventional HTML notation.

Assigning the button ...

Get Palm webOS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.