• <tfoot id='OVofn'></tfoot>

    <legend id='OVofn'><style id='OVofn'><dir id='OVofn'><q id='OVofn'></q></dir></style></legend>

      <small id='OVofn'></small><noframes id='OVofn'>

        • <bdo id='OVofn'></bdo><ul id='OVofn'></ul>
        <i id='OVofn'><tr id='OVofn'><dt id='OVofn'><q id='OVofn'><span id='OVofn'><b id='OVofn'><form id='OVofn'><ins id='OVofn'></ins><ul id='OVofn'></ul><sub id='OVofn'></sub></form><legend id='OVofn'></legend><bdo id='OVofn'><pre id='OVofn'><center id='OVofn'></center></pre></bdo></b><th id='OVofn'></th></span></q></dt></tr></i><div id='OVofn'><tfoot id='OVofn'></tfoot><dl id='OVofn'><fieldset id='OVofn'></fieldset></dl></div>

        libgdx 的文本字段中的特殊字符不起作用

        时间:2023-05-19
        • <small id='ztn9y'></small><noframes id='ztn9y'>

            <legend id='ztn9y'><style id='ztn9y'><dir id='ztn9y'><q id='ztn9y'></q></dir></style></legend>

              <tfoot id='ztn9y'></tfoot>

                <bdo id='ztn9y'></bdo><ul id='ztn9y'></ul>
                  <tbody id='ztn9y'></tbody>

              • <i id='ztn9y'><tr id='ztn9y'><dt id='ztn9y'><q id='ztn9y'><span id='ztn9y'><b id='ztn9y'><form id='ztn9y'><ins id='ztn9y'></ins><ul id='ztn9y'></ul><sub id='ztn9y'></sub></form><legend id='ztn9y'></legend><bdo id='ztn9y'><pre id='ztn9y'><center id='ztn9y'></center></pre></bdo></b><th id='ztn9y'></th></span></q></dt></tr></i><div id='ztn9y'><tfoot id='ztn9y'></tfoot><dl id='ztn9y'><fieldset id='ztn9y'></fieldset></dl></div>
                  本文介绍了libgdx 的文本字段中的特殊字符不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我可以使用 setText("åäö") 但如果我在键盘上键入它不会显示,这也不起作用

                  I can use setText("åäö") but if I type on my keyboard it doesn't show up, this doesn't work either

                              public void keyTyped(TextField textField, char key) {
                                  JOptionPane.showMessageDialog(new JFrame(), key);
                              }
                  

                  奇怪的是它不能在 mac 上运行,但它在 Windows 上运行,有人对此有答案吗?谢谢!

                  The strange thing is that it doesn't work on mac but it does work on Windows, does anyone have an answer for that? Thank You!

                  这是另一个主题相似的问题!

                  Here's another question with a similarly topic!

                  如何从 Libgdx 中的特殊字符获取输入?

                  我已尝试获取 ascii 值并将其通过

                  I have tried to get the ascii value and puting it through

                  Gdx.input.isKeyPressed(ascii value);
                  

                  但它不起作用.我已将项目编码设置为 UTF-8,并且可以打印特殊字符,例如 åäö.

                  but it doesn't work. I have set my project encoding to UTF-8 and I can print special characters like åäö.

                  我试过这个

                  Gdx.input.setInputProcessor(new InputProcessor() {
                  
                          @Override
                          public boolean keyDown(int keycode) {
                              // TODO Auto-generated method stub
                              return false;
                          }
                  
                          @Override
                          public boolean keyUp(int keycode) {
                              // TODO Auto-generated method stub
                              return false;
                          }
                  
                          @Override
                          public boolean keyTyped(char character) {
                              System.out.println(character);
                              return false;
                          }
                  
                          @Override
                          public boolean touchDown(int screenX, int screenY, int pointer, int button) {
                              return false;
                          }
                  
                          @Override
                          public boolean touchUp(int screenX, int screenY, int pointer, int button) {
                              return false;
                          }
                  
                          @Override
                          public boolean touchDragged(int screenX, int screenY, int pointer) {
                              return false;
                          }
                  
                          @Override
                          public boolean mouseMoved(int screenX, int screenY) {
                              return false;
                          }
                  
                          @Override
                          public boolean scrolled(int amount) {
                              return false;
                          }
                  
                      });
                  

                  没有打印 åäö

                  推荐答案

                  更新

                  这似乎与 OSX 上 lwjgl 中的 unicode 字符错误有关:[已修复] Unicode 输入

                  It seems, that this is related to a bug with unicode characters in lwjgl on OSX: [FIXED] Unicode input

                  如果您更新到最新的 lwjgl 库 2.9.1,这应该可以修复.来自更新日志:

                  If you update to the latest lwjgl library 2.9.1 this should be fixed. From the changelog:

                  2013-10-13 kappaOne

                  2013-10-13 kappaOne

                  • .../org/lwjgl/opengl/MacOSXNativeKeyboard.java,src/native/macosx/org_lwjgl_opengl_Display.m:修复键盘键返回 Unicode 字符而不是 ASCII 字符的代码

                  请参阅:2.9.1-changelog.txt

                  原答案

                  如何从 Libgdx 中的特殊字符中获取输入?

                  How do you get input from special characters in Libgdx?

                  可以通过调用Gdx.input.setInputProcessor(inputProcessor);实现com.badlogic.gdx.InputProcessor接口设置当前输入处理器;

                  然后您应该能够在 InputProcessor#keyTyped(char c) 方法中接收有关所有键入字符(特殊或非特殊字符)的通知.

                  Then you should be able to receive notifications about all typed characters (special or not) in the method InputProcessor#keyTyped(char c).

                  实际上这或多或少是 TextField 类所做的(不完全是,它通过扩展 com.badlogic.gdx.scenes.scene2d.InputListener 来监听输入).

                  Actually this is more or less, what the class TextField does (not exactly, it listens for input by extending com.badlogic.gdx.scenes.scene2d.InputListener).

                  我快速浏览了TextFields keyTyped方法的相关源码:

                  I had a quick look at the relevant source code of TextFields keyTyped method:

                  [...]
                  if (font.containsCharacter(character)) {
                     // here the character gets added to the text field
                  }
                  [...]
                  

                  看来,文本字段的字体必须支持字符,否则不会显示.我没有 mac 来测试这个,但我猜,你的 mac 上默认使用的 BitmapFont 不支持特殊字符.尝试为 TextField 设置不同的 BitmapFont(参见 TextField.setStyle(TextFieldStyle style)),看看是否能解决问题.

                  So it seems, that the font of the text field must support the character, otherwise it will not be displayed. I have no mac to test this, but I would guess, that the BitmapFont used by default on your mac does not support the special characters. Try to set a different BitmapFont for the TextField (see TextField.setStyle(TextFieldStyle style)) and see if this solves the problem.

                  这篇关于libgdx 的文本字段中的特殊字符不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:视频驱动程序不支持 OpenGL 下一篇:Libgdx 3d 中的光线投射

                  相关文章

                  最新文章

                      <legend id='aROAd'><style id='aROAd'><dir id='aROAd'><q id='aROAd'></q></dir></style></legend>
                      <tfoot id='aROAd'></tfoot>
                      • <bdo id='aROAd'></bdo><ul id='aROAd'></ul>
                    1. <small id='aROAd'></small><noframes id='aROAd'>

                      <i id='aROAd'><tr id='aROAd'><dt id='aROAd'><q id='aROAd'><span id='aROAd'><b id='aROAd'><form id='aROAd'><ins id='aROAd'></ins><ul id='aROAd'></ul><sub id='aROAd'></sub></form><legend id='aROAd'></legend><bdo id='aROAd'><pre id='aROAd'><center id='aROAd'></center></pre></bdo></b><th id='aROAd'></th></span></q></dt></tr></i><div id='aROAd'><tfoot id='aROAd'></tfoot><dl id='aROAd'><fieldset id='aROAd'></fieldset></dl></div>