站内搜索: 请输入搜索关键词
当前页面: 图书首页 > MIDP Style Guide for the Java 2 Platform, Micro Edition

MIDP Style Guide for the Java 2 Platform, Micro Edition

[ directory ] Previous Section Next Section

6.3 Input Modes

Input modes enable applications to request that a MIDP implementation make it convenient for the user to enter certain characters. For example, an application may have a text field or text box that has a NUMERIC constraint. To make data entry more convenient, the application could also request an input mode that makes it easy for the user to enter numbers.

Each input mode has a name, which typically describes its character set. An application requests an input mode by name. For example, the application could request an input mode of IS_LATIN_DIGITS to make it more convenient for the user to enter a number.

MIDP Implementors

Strongly Recommend: graphics/bulb1_icon.gif Indicate the device's current text mode to the user. Figure 6.7 shows two text modes, one numeric and one alphabetic, and points out the device's text input mode indicators.

Figure 6.7. Input Mode Indicators

graphics/06fig07.gif

Possible input modes include unicode character blocks, as defined in the J2SE platform's java.lang.Character.UnicodeBlock class (such as UCB_BENGALI), and input subsets as defined in the J2SE platform's java.awt.im.InputSubset class (such as IS_LATIN_DIGITS). In addition, MIDP defines MIDP_UPPERCASE_LATIN, the subset of IS_LATIN that corresponds to uppercase Latin letters, and MIDP_LOWERCASE_LATIN, the subset of IS_LATIN that corresponds to lowercase Latin letters. Implementations can also create character subsets; see the MIDP 2.0 Specification [19] for more information.

Strongly Recommend: graphics/bulb1_icon.gif Decide which input modes you will support, and publish them.

Strongly Recommend: graphics/bulb1_icon.gif If you are unable to fulfill an application's input mode request, or the input mode is inconsistent with the text box or text field's current constraint setting, use a default input mode instead.

Recommend: graphics/bulb2_icon.gif Change your default input mode according to the constraints of the text box or text field. For example, if the current constraint is NUMERIC, you could use a default input mode that makes it easy for the user to enter numerals, whereas if the constraint is ANY, your default input mode might allow the characters corresponding to the device's locale.

6.3.1 Requesting an Input Mode

Application Developers

Recommend: graphics/bulb2_icon.gif Request an input mode before the text box or text field is visible. If editing is already in progress, your request will not change the current input mode; it will take effect the next time the user initiates editing of this text object.

MIDP Implementors

Strongly Recommend: graphics/bulb1_icon.gif Use the requested input mode, if possible, whenever the user initiates the editing of a text box or text field, but allow the user to switch input modes at any time. Users must be permitted to enter any character that is allowed within the constraints of the text box or text field.

Strongly Recommend: graphics/bulb1_icon.gif If an application uses constraints and modifiers that conflict with its requested input mode, you must honor the constraints and modifiers. You are permitted to ignore the input mode in order to fulfill the requirements of the constraints and modifiers.

6.3.2 Providing Symbols Not on the Device

MIDP Implementors

Consider: Use a symbol table to show extra symbols that are not easily available from the device. If the device already has such a symbol table, consider giving the users access to it. Figure 6.8 shows a symbol table.

Figure 6.8. Symbol Table for Entering Characters

graphics/06fig08.gif

    [ directory ] Previous Section Next Section