JavaFX WebView/WebEngine为每个文本输入自动显示在屏幕键盘上 [英] JavaFX WebView / WebEngine show on-screen-keyboard automatically for each text input

查看:344
本文介绍了JavaFX WebView/WebEngine为每个文本输入自动显示在屏幕键盘上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景/背景:

我正在使用JavaFX开发基于触摸屏的信息亭应用程序.该应用程序集成了浏览器– WebView.问题是所有用户输入都必须通过屏幕键盘(SW键盘)进行输入

I am developing touch screen based kiosk application with JavaFX. The app integrates browser – WebView. The problem is that all user inputs have to be made through on screen keyboard (SW keyboard)

最好在WebView/WebEngine上注册一个事件处理程序,以获取任何焦点丢失的HTML文本输入元素,这样我就可以在屏幕键盘上显示/隐藏.
即使我搜索了Internet,也没有找到这种功能.

It would be nice to have an option to register an event-handler on WebView/WebEngine for any HTML text input element got/lost focus, so that I could show/hide on-screen-keyboard.
Even though I searched the Internet, I did not find this kind of feature.

我的问题:

JavaFX/WebView是否对这些情况提供任何支持?

Does JavaFX / WebView provides any support for these cases?

如果您要解决此问题,您将采取什么方法?

If you were to tackle this problem, what would be your approach to that?

到目前为止我的解决方案:

我有一个小按钮(在屏幕的一个角),允许用户显示/隐藏屏幕上的键盘.由于他们必须手动执行此操作,因此非常烦人.尤其是在浏览(使用信息)和文本输入经常更改的网站上.

I have a small button (at one corner of the screen) that allows user to show/hide on-screen-keyboard. Since they have to do that manually, it is quite annoying. Especially on sites where browsing (consuming information) and text inputs changes frequently.

推荐答案

最好在WebView/WebEngine上注册一个事件处理程序,以获取任何焦点丢失/丢失的HTML文本输入元素,这样我就可以在屏幕键盘上显示/隐藏.

It would be nice to have an option to register an event-handler on WebView/WebEngine for any HTML text input element got/lost focus, so that I could show/hide on-screen-keyboard.

执行此操作的潜在策略:

A potential strategy for doing this:

  1. jdk8预览开始.
  2. 使用-Dcom.sun.javafx.isEmbedded=true运行应用程序以启用虚拟键盘.
  3. 使用webengine.executeScript技术将jQuery嵌入目标页面.
  4. jQuery焦点处理程序绑定到相关的html元素.
  5. 在jQuery焦点处理程序中,进行从JavaScript到Java的调用.
  6. 收到呼叫通知后,请使用 JavaFX的虚拟键盘.
  7. 当用户在键盘上输入值时,请执行executeScript调用以设置相应html字段的值.
  1. Start with a jdk8 preview.
  2. Run the application with -Dcom.sun.javafx.isEmbedded=true to enable the virtual keyboard.
  3. Use a webengine.executeScript technique to embed jQuery into the target page.
  4. Bind a jQuery focus handler to the relevant html elements.
  5. In the jQuery focus handler make an Upcall from JavaScript to Java.
  6. Upon receiving the upcall make use of JavaFX's Virtual Keyboard.
  7. As the user enters values into the keyboard, make executeScript calls to set the value of the corresponding html field.

某些部分可能会有点(或完全)片状,但也许其他部分可能对您有用.

Some parts will likely be a bit (or totally) flaky, but perhaps other parts may prove useful to you.

将来,如果嵌入式设备上的触摸屏平台支持WebView,我想开箱即用虚拟键盘就可以很好地工作.

In the future, if WebView is supported on touchscreen platforms on embedded devices, I'm guessing that out of the box it will work well with a virtual keyboard.

这篇关于JavaFX WebView/WebEngine为每个文本输入自动显示在屏幕键盘上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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