GWT:文本框不会在Ipad上显示光标 [英] GWT: Textbox doesn't show Cursor on Ipad

查看:78
本文介绍了GWT:文本框不会在Ipad上显示光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个文本框,该文本框可以显示GWT的分数. 因此,我有一个Canvas,可以绘制我想要的东西并接收KeyEvent和MouseEvent.

I am trying to implement a Textbox that can show fractions with GWT. Therefor I have an Canvas were I can draw what I want and receive KeyEvents and MouseEvents.

但是在Ipad(Safarie和Chrome)上,软件键盘没有显示,因此我创建了一个Composite,将Canvas与Textbox结合起来,在画布上的每个键或鼠标事件发生后便获得了焦点.

But on Ipad (Safarie and Chrome) the software keyboard does not show, so I created an Composite and combined the Canvas with a Textbox witch gets the focus after each key or mouse Event on the Canvas.

但是软键盘不会每次都显示,所以我尝试了一下,可以看到,文本框似乎获得了焦点(它变成了蓝色的边界),但并不总是显示光标.

But the softkeyboard does not show up every time so I tried a bit and can see, that the Textbox seems to get the focus (it gets a blue boarder) but does not always show the cursor.

这在我的笔记本电脑上不会发生.

This does not happen on my Notebook.

聚焦和显示光标之间有什么区别吗?

Is there any difference between being focused and showing the cursor?

我尝试过:

  • 设置光标位置
  • 设置文本框的文本.

任何帮助,我们将不胜感激, 克里斯多夫(Christoph)

Any help would be appreciated, Christoph

    public void setFocus(boolean b) {
    //  if (hasFocus) {
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            public void execute () {
                t.setFocus(b);
            }
           });
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            public void execute () {
                box.setFocus(true);
                box.setText("x");
                box.setCursorPos(0);
//              box.setVisible(false);
//              box.setVisible(true);
            }
           });

  //        t.setFocus(b);
//      box.setFocus(b);

//      }
    }

推荐答案

iOS浏览器不允许以编程方式设置焦点,除非直接响应用户交互(即触摸).我相信原因是为了防止网站无缘无故地打开虚拟键盘.

The iOS browsers don't allow the focus to be set programmatically unless directly in response to a user interaction (i.e. a touch). I believe the reason is to prevent websites bringing up the virtual keyboard for no reason.

不利之处在于,它会为出于正当理由使用它的网站掩盖setFocus().您不能在延迟命令中调用setFocus(),因为这不算作对用户交互的直接响应.

The downside is that it clobbers setFocus() for websites that want to use it for legitimate reasons. You can't call setFocus() in a deferred command because that doesn't count as a direct response to the user interaction.

(更确切地说,您可以 用延期命令调用setFocus(),但是您发现的效果不理想.)

(To be more precise, you can call setFocus() in a deferred command, but it won't have the desired effect as you found out.)

这篇关于GWT:文本框不会在Ipad上显示光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆