I'm currently working on a midlet in which the main application screen is implemented as a subclass of Canvas. It's basically a Model/View/Controller architecture and there is a big switch statement within the canvas subclass which inspects the current controller state within the paint() method and the correct screen within the application flow is rendered.
I've a new requirement which is to place an edit control on one of the screens. I want the user to be able to enter their UK postcode. Since subclassing Canvas requires that you write your own controls I took the easy way out by having the application put up a regular MIDP high-level Form control with a data entry TextField on it and a submit button (handled by the Form's commandlistener). The trouble is.. when the Form is dismissed and application control returns to the low level canvas the key handling seems to have become messed up.
The keyPressed(int keyCode) method for low level key events doesn't seem to be absorbing key press events and in fact the app quits when the left key is pressed (when run in the WTK emulator.. I'm using the Sun DefaultColorPhone emulator skin). I've tried to use form.setCommandListener(null) within the commandAction callback so as to disable the high level command handling once the Form has been dismissed but to no avail. Has anyone tried this approach of mixing low and high level APIs. Failing that has anyone coded
a data entry field for the low level Canvas API?