如何在游戏中获得原生键盘?

发布于 2024-11-08 23:51:39 字数 144 浏览 0 评论 0原文

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

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

提前致谢 克里斯

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

习ぎ惯性依靠 2024-11-15 23:51:39

不。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。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文