NumericInputModepublic class NumericInputMode extends BasicInputMode An InputMode instance which processes the numeric 0-9 keys
as their literal numeric values. |
Fields Summary |
---|
protected char[] | numericKeyMapThe numeric key map. | protected char[] | decimalKeyMapThe decimal key map. | protected char[] | phoneNumericKeyMapThe phone numeric key map. | protected char[] | anyKeyMapThe any numeric key map. | private static final boolean[] | isMapinput subset x constraint map |
Constructors Summary |
---|
public NumericInputMode()Default constructor. Init key maps for all constraints
String numericInLine = Resource.getString(
ResourceConstants.LCDUI_TF_NUMERIC_KEY_MAP);
numericKeyMap = getMapByLine(numericInLine);
String decimalInLine = Resource.getString(
ResourceConstants.LCDUI_TF_DECIMAL_KEY_MAP);
decimalKeyMap = getMapByLine(decimalInLine);
String phoneInLine = Resource.getString(
ResourceConstants.LCDUI_TF_PHONE_KEY_MAP);
phoneNumericKeyMap = getMapByLine(phoneInLine);
String anyInLine = Resource.getString(
ResourceConstants.LCDUI_TF_NUMERIC_ANY_KEY_MAP);
anyKeyMap = getMapByLine(anyInLine);
|
Methods Summary |
---|
protected char[] | getCharOptions(int lastKey)Gets the possible matches for the key code
char[] chars = null;
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
" getCharOptions lastKey=" + lastKey);
}
switch (lastKey) {
case Canvas.KEY_NUM0:
chars = keyMap[0];
break;
case Canvas.KEY_NUM1:
chars = keyMap[1];
break;
case Canvas.KEY_NUM2:
chars = keyMap[2];
break;
case Canvas.KEY_NUM3:
chars = keyMap[3];
break;
case Canvas.KEY_NUM4:
chars = keyMap[4];
break;
case Canvas.KEY_NUM5:
chars = keyMap[5];
break;
case Canvas.KEY_NUM6:
chars = keyMap[6];
break;
case Canvas.KEY_NUM7:
chars = keyMap[7];
break;
case Canvas.KEY_NUM8:
chars = keyMap[8];
break;
case Canvas.KEY_NUM9:
chars = keyMap[9];
break;
case Canvas.KEY_STAR:
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
" getCharOptions got star");
}
chars = keyMap[10];
break;
case Canvas.KEY_POUND:
chars = keyMap[11];
break;
default:
// This can actually happen if the Timer went off without
// a pending key, which can sometimes happen.
break;
}
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"getCharOptions returning:");
}
for (int i = 0; i < chars.length; i++) {
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
chars[i] + ",");
}
}
return chars;
| public java.lang.String | getCommandName()Returns the command name which will represent this InputMode in
the input menu
return getName();
| public boolean[][] | getIsConstraintsMap()Returns the map specifying this input mode is proper one for the
particular pair of input subset and constraint. The form of the map is
|ANY|EMAILADDR|NUMERIC|PHONENUMBER|URL|DECIMAL|
---------------------------------------------------------------------
IS_FULLWIDTH_DIGITS |t|f| t|f | t|f | t|f |t|f| t|f |
IS_FULLWIDTH_LATIN |t|f| t|f | t|f | t|f |t|f| t|f |
IS_HALFWIDTH_KATAKANA |t|f| t|f | t|f | t|f |t|f| t|f |
IS_HANJA |t|f| t|f | t|f | t|f |t|f| t|f |
IS_KANJI |t|f| t|f | t|f | t|f |t|f| t|f |
IS_LATIN |t|f| t|f | t|f | t|f |t|f| t|f |
IS_LATIN_DIGITS |t|f| t|f | t|f | t|f |t|f| t|f |
IS_SIMPLIFIED_HANZI |t|f| t|f | t|f | t|f |t|f| t|f |
IS_TRADITIONAL_HANZI |t|f| t|f | t|f | t|f |t|f| t|f |
MIDP_UPPERCASE_LATIN |t|f| t|f | t|f | t|f |t|f| t|f |
MIDP_LOWERCASE_LATIN |t|f| t|f | t|f | t|f |t|f| t|f |
NULL |t|f| t|f | t|f | t|f |t|f| t|f |
return isMap;
| public java.lang.String | getName()Returns the display name which will represent this InputMode to
the user, such as in a selection list or the softbutton bar.
return Resource.getString(ResourceConstants.LCDUI_TF_NUMERIC);
| protected boolean | setKeyMap(int constraints, boolean longPress)Set the corresponding key map.
char[][] oldKeyMap = keyMap;
if (constraints == TextField.PHONENUMBER) {
keyMap = phoneNumericKeyMap;
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"setting keymap to phone");
}
} else if (constraints == TextField.DECIMAL) {
keyMap = decimalKeyMap;
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"setting keymap to decimalKeyMap");
}
} else if (constraints == TextField.NUMERIC) {
keyMap = numericKeyMap;
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"setting keymap to numeric");
}
} else {
keyMap = anyKeyMap;
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"setting keymap to any");
}
}
return oldKeyMap != keyMap;
| public boolean | supportsConstraints(int constraints)This method is called to determine if this InputMode supports
the given text input constraints. The semantics of the constraints
value are defined in the javax.microedition.lcdui.TextField API.
If this InputMode returns false, this InputMode must not be used
to process key input for the selected text component.
// Numbers are allowed by any input constraints
return true;
|
|