Package totalcross.ui
Class PreprocessKey
- java.lang.Object
-
- totalcross.ui.PreprocessKey
-
public abstract class PreprocessKey extends java.lang.ObjectClass used to customize the way that Edit and MultiEdit handle keys. Useful, for example, to handle devices with special keypads and translate them into standard characters. You have to extend the preprocess method and change the key to one you may want to use. Then, assign an instance of the class to theinstancemember, and the Edit and MultiEdit will use them It has two handy methods, to be used to map char sequences. Below, an implementation for the the MC67.PreprocessKey.instance = new PreprocessKey() { private final char[][] keys = { {'.',','}, {'\0'}, {'a','b','c'}, {'d','e','f'}, {'g','h','i'}, {'j','k','l'}, {'m','n','o'}, {'p','q','r','s'}, {'t','u','v'}, {'w','x','y','z'}, }; protected char[] getKeySet(Control target, KeyEvent e) { if (e.type == KeyEvent.KEY_PRESS && (Settings.onJavaSE || (e.modifiers & SpecialKeys.SYSTEM) != 0)) // use only if key came from physical keyboard { char c = Convert.toLowerCase((char)e.key); for (int i = 0; i < keys.length; i++) if (keys[i][0] == c) return keys[i]; } return null; } public void preprocess(Control target, KeyEvent e) { handleKeypadPress(target, e); } };
-
-
Field Summary
Fields Modifier and Type Field Description static PreprocessKeyinstancestatic intMAX_DELAYMaximum millis delay to consider that the user is repeating the current key
-
Constructor Summary
Constructors Constructor Description PreprocessKey()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected char[]getKeySet(Control target, KeyEvent e)protected voidhandleKeypadPress(Control target, KeyEvent e)abstract voidpreprocess(Control target, KeyEvent ke)
-
-
-
Field Detail
-
instance
public static PreprocessKey instance
-
MAX_DELAY
public static int MAX_DELAY
Maximum millis delay to consider that the user is repeating the current key
-
-