Handling virtual keyboard for Canvas and CustomItem

The full touch platform provides a virtual keyboard for key input. The Virtual Keyboard API allows MIDlets to launch a virtual keyboard for Canvas and Canvas-based elements, such as GameCanvas and FullCanvas , and for active CustomItem elements in portrait mode. The Virtual Keyboard API does not provide any editor functionality. It merely launches and controls the virtual keyboard provided by the platform. The Virtual Keyboard API is mainly intended for MIDlets that use low-level UI elements and rely on key input.

On full touch devices, the canvas size available to the application (when not in full screen mode) changes from 240x342 to 240x142 when the virtual keyboard pops up. This causes an automatic re-paint. This might affect the MIDlet if the paint method does not have an idempotent scope.

For more information on using the Virtual Keyboard API, see Physical keys and virtual keyboard.

Hiding the Open Keypad command

For MIDlets with low-level UI components, the command “Open Keypad” is included, by default, under Option menu of full touch devices. This is in order to keep applications backward compatible with touch and type, and non-touch devices, especially if an application uses canvas-like drawing and expects to receive input from the physical keypad.

If your MIDlet does not require keyboard input, you can hide the default Open Keypad command in the Options menu.

To hide the open keypad command, use the method:

VirtualKeyboard.hideOpenKeypadCommand

Check type of the physical keyboard by querying System.getProperty("com.nokia.keyboard.type").

If the returned type String equals "None", the current device is a full touch device.

            String keyboardType = System.getProperty("com.nokia.keyboard.type");
            if (keyboardType.equals("None")) {
                // full touch device detected
                com.nokia.mid.ui.VirtualKeyboard.hideOpenKeypadCommand(true);
            }

Repositioning the text input area

The virtual keyboard covers part of the display and it is not possible to position it. This results in the area receiving the touch input getting covered by the virtual keyboard. This can happen only for low level UI components like Canvas. If this happens, the result of any input from the virtual keyboard is not visible to the user as long as the virtual keyboard is displayed.

When you are in portrait mode, virtual keyboard will show on top of the application screen. If you are in landscape mode, you only see the virtual keyboard and one TextField and moving between fields is cumbersome.

When not in full screen mode, the canvas is repainted each time the virtual keyboard appears and disappears and a new value is returned for the getHeight() method of Canvas. If the TextEditor constructor with height in pixels is used, then when repainting the canvas, you can get the new height of the Canvas and resize the TextEditor accordingly.


Last updated 9 October 2013

Back to top

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×