1

我有一个使用 LWUIT 开发的游戏。现在我正在游戏中实现全触摸。它是一个多人游戏,所以有一些选项,如聊天和登录。当我们按下聊天时,我们需要在字段中输入字符。我的问题是

当我们按下聊天按钮时是否可以调用本机键盘。?

在此先感谢克里斯

4

1 回答 1

1

不,MIDP 不包含这样的 API。您可以使用 LWUIT 的虚拟键盘(不是本机的)并定义您想要的任何字符集,如下所述:http: //lwuit.blogspot.com/2010/06/pimp-virtualkeyboard-by-chen-fishbein.html

您可以使用显示类显示它。

在 Symbian 设备上,如果您没有定义一些 jad 属性,触摸键盘将始终可见,您将无法隐藏它以查看更多详细信息:http: //lwuit.blogspot.com/2009/11/optimized -for-touch.html

再次查看这个问题,我认为 VKB 对于永远在线的键盘更换来说可能是一种过度杀伤力。只需将您的内容放在 BorderLayout 的中心,然后在南部粘贴一个容器,如下所示:

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);
    }
});

其余的和火很容易添加(同样的事情)注意 getKeyCode 已被弃用但现在应该可以工作,因为我们没有替代该 API。

于 2011-05-22T03:49:21.577 回答