JavaFX WebView / WebEngine show on-screen-keyboard automatically for each text input

百般思念 提交于 2019-12-01 22:20:12

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. 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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!