12.1 Types of Abstract Commands
An abstract command's type is a hint to the MIDP implementation of the command's purpose. There are eight types of abstract commands: BACK, SCREEN, ITEM, OK, CANCEL, STOP, HELP, and EXIT. All can be associated with a displayable. Only type ITEM should be associated with a form item.
Use the command-type hint to take advantage of any corresponding device policies. For example, one command type is BACK, and it typically causes an application to return to a previous state. Most phone designs have a policy regarding which button is used for this operation. MIDP implementations can use the command-type hint to take advantage of this policy.
12.1.1 The BACK Command Type
The BACK command type is designed to be used to return to a previous state in the application. A screen might have multiple commands of type BACK.
Use the BACK command type for actions that return users to the previous screen, to the start of an action that involves multiple screens, or to the start of your MIDlet. (The example commands could have the labels Back, Start Over, and Home.) In other words, use the BACK command type to return the user to any previous location that makes sense in your application.
12.1.2 The SCREEN Command Type
The SCREEN command type is designed to be used for actions that affect the entire screen or application. A screen might have multiple commands of type SCREEN.
Use the SCREEN command type for setting application preferences, moving to the next screen in an application, saving the contents of a text box, and other actions that are not associated with a single item or element on the screen. If a command is associated with a selected item or element, use the ITEM command type instead. (See page 170 for more information.)
12.1.3 The ITEM Command Type
The ITEM command type is designed to be used for actions that affect a single item or element on a screen. For example, item-specific abstract commands should use this command type. A screen might have multiple commands of type ITEM.
Attach a command of type ITEM to the screen that contains the items when a command applies to each item on the screen. Attach a command of type ITEM to the item itself if it applies to only some of the items on the screen.
For example, consider a screen that displays a list of email messages as hyperlink string items (see "Buttons and Hyperlinks" on page 97 for information). Reading the selected message would best be thought of as an ITEM command, and, because the action is associated with every item in the list, the command of type ITEM should be associated with the screen. Viewing any attachment of the selected message would also best be thought of as an ITEM command. Because the action is associated with only some items (those that have attachments), it should be associated with the individual items. (See page 170 for more information.)
12.1.4 The OK Command Type
The OK command type is designed to be used to provide a positive response to a query. A screen typically has at most one command of type OK.
Use a command of type OK on a confirmation alert screen. (See "Alerts" starting on page 125 for information.) Figure 12.1 shows an alert that asks the user to confirm buying a set of tickets. The response indicating that the tickets should be bought is an abstract command of type OK. The command has the label Buy.
Figure 12.1. Screen with OK and CANCEL Abstract Commands
12.1.5 The CANCEL Command Type
The CANCEL command is designed to be used to provide a negative response to a query. A screen typically has at most one command of type CANCEL.
Use the CANCEL command type with a Confirmation Alert screen. (See "Alerts" starting on page 125 for information.) Figure 12.1 shows an alert that asks the user to confirm buying a set of tickets. The response indicating that the tickets should not be bought is an abstract command of type CANCEL. The command has the label Cancel.
12.1.6 The STOP Command Type
The STOP command is designed to be used to stop a process other than the entire MIDlet. (To stop the entire MIDlet, use a command of type EXIT.) A screen typically has at most one command of type STOP.
Use the STOP command in conjunction with noninteractive gauges. (See "Gauges" on page 107 for more information.) For example, consider a MIDlet that accesses a web page. During the time that the MIDlet sends the request and waits for a reply, it should show a screen that gives the user feedback that the MIDlet is working. The feedback screen should at least have a noninteractive gauge and an abstract command of type STOP. If the user chooses the abstract command (for example, because getting the web page is taking too long), the command should immediately stop the download of the page.
12.1.7 The HELP Command Type
The HELP command type is designed to be used for tutorials, Help screens, and other information that assists the user. A screen might have multiple commands of type HELP.
In addition to using the HELP command type for instructions and other help, use them for your applications' About boxes so that they show up in a consistent location from device to device.
12.1.8 The EXIT Command Type
The EXIT command type is designed to be used to enable the user to exit the MIDlet. (To stop a process that the MIDlet is performing without stopping the MIDlet itself, use a command of type STOP.) A screen typically has at most one command of type EXIT.
Give users a way to exit a MIDlet, in case an ill-designed or broken MIDlet does not give users a way to move from a screen. One way to do this is to add a command of type EXIT to each screen.
When the user exits the MIDlet, return to the device's main application screen. Usability studies have shown that exiting to an intermediate screen (for example, one where the user chooses a MIDlet from the current MIDlet's MIDlet suite) is confusing. (See "Launching and Exiting MIDlet Suites" on page 190 for more information.)
12.1.9 SCREEN Versus ITEM Command Types
It can sometimes be difficult to decide whether a particular command is of type SCREEN or ITEM. Some actions can be either ITEM or SCREEN command types, depending on their context. For example, consider reading messages in an email application. On a screen that listed email messages, reading the selected message would best be thought of as a command of type ITEM. On the other hand, a command that allows users to switch from another task (such as writing a message) to reading messages would be best thought of as command of type SCREEN. If the application made both actions available to the user, it should have two abstract commands: one of type ITEM and the other of type SCREEN. It would use the two commands on different screens.