1

i have a game developed using LWUIT.now i am implementing full touch in game.it is a multi player game so there are some options like chat and login. when we press on chat we need to enter the characters in the field. my question is

is it possible to invoke the native keypad when we press on the chat button .?

thanks in advance kris

Kris
  • 891
  • 2
  • 18
  • 41

1 Answers1

1

No. MIDP doesn't include such an API. You can use LWUIT's virtual keyboard (which isn't native) and define any character set you want as explained here: http://lwuit.blogspot.com/2010/06/pimp-virtualkeyboard-by-chen-fishbein.html

You can show it using the display class.

On Symbian devices if you do not define some jad properties, a touch keypad will be always visible and you won't be able to hide it for more details look here: http://lwuit.blogspot.com/2009/11/optimized-for-touch.html

Looking at the question again I'm thinking the VKB is probably an overkill for an always on keypad replacement. Just place your content in the center of a BorderLayout and stick a container in the south something like this:

addComponent(BorderLayout.CENTER, myUI);
Container keypad = new Container(new GridLayout(2, 2));
addComponent(BorderLayout.SOUTH, keypad);
Button up = new Button("Up");
Button down = new Button("Down");
Button left = new Button("Left");
Button right = new Button("Right");
up.setFocusable(false);
down.setFocusable(false);
left.setFocusable(false);
right.setFocusable(false);
keypad.addComponent(up);
keypad.addComponent(down);
keypad.addComponent(left);
keypad.addComponent(right);
up.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ev) {
       int up = Display.getInstance().getKeyCode(Display.GAME_UP);
       Display.getInstance().getCurrentForm().keyPressed(up);
       Display.getInstance().getCurrentForm().keyReleased(up);
    }
});

The rest and fire are pretty trivial to add (same thing) notice that getKeyCode is deprecated but should work for now since we have no alternative to that API.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • hi Shai Almog thank you for your support. can you pls give me a sample midlet or something , so i can easily understand how to invoke the LWUIT vkeypad. it will be very helpful. – Kris May 23 '11 at 04:56
  • 1
    I updated my answer to reflect an easier solution to your issue – Shai Almog May 23 '11 at 07:46