其他地方触发时的 GWT 焦点问题
这是我的设置:
- 我有一个按钮和一个文本框
- 文本框有一个“onFocus”处理程序,它触发“selectAll”方法
- 按钮有一个“onClick”处理程序,它执行以下操作:
- 显示文本框
- textbox.focus(true) 和
- textbox.selectAll();
但事实并非如此(在移动设备上)。 问题是:这适用于 FF 和 Safari - 但不适用于移动 WebKit。当我单击按钮时,字段会获得焦点并选择一毫秒(有时甚至不是),然后返回到焦点按钮......
A 已经尝试插入一个计时器,然后它会进行焦点 - 也不起作用。
我还尝试捕获所有事件并阻止它们 - 因为 onClick 之后按钮会触发 onFocus 事件。我什至尝试从按钮的 onFocus 事件将焦点设置到文本框。没有机会。
还有其他想法吗?
Here is my setup:
- I have a button and a textbox
- The textbox has an "onFocus" Handler which triggers the "selectAll" method
- the button has an "onClick" Handler which does the following:
- show textbox
- textbox.focus(true) and
- textbox.selectAll();
But it does not (on mobile devices).
The thing is: this works in FF and Safari - but it does not on mobile WebKit. When I click the button the field gets focused and selected for a milisecond (sometimes not even that) and then returns to focus the button …
A already tried to insert a Timer which then would do the focus - does not work either.
I also tried to capture all events and prevent them - because there is an onFocus event being fired by the button after onClick. I even tried setting the focus to the textbox from the onFocus event of the button. No chance.
Any other Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是 GWT 不编译适用于触摸设备的 Javascript 代码。您将需要创建自己的实现。
看一下这篇文章:支持多点触控事件
The problem is that GWT doesn't compile Javascript code for touch devices. You will need to create your own implementation.
Take a look to this article: Supporting multi-touch events