Class 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 the
instance
member, 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);
}
};