javafxports / openjdk-jfx

The openjfx repo has moved to:
https://github.com/openjdk/jfx
GNU General Public License v2.0
1.01k stars 145 forks source link

Virtual keyboard not shown for textfields in WebView #131

Open tiainen opened 6 years ago

tiainen commented 6 years ago

The JavaFX virtual keyboard is not shown when an input field of type text in WebView receives focus.

I have found the cause to be that the editable property of the textfield is incorrectly set. The editable property of the textfield should be set to the inverse of the readonly attribute that is defined on the input field. The following line contains the culprit: https://github.com/javafxports/openjdk-jfx/blob/develop/modules/javafx.web/src/main/java/com/sun/javafx/webkit/theme/RenderThemeImpl.java#L456

When inverting the boolean value, the virtual keyboard is correctly shown as expected.

tiainen commented 6 years ago

There is another issue when the virtual keyboard is correctly applied after applying the change mentioned above. The keyboard events from the virtual keyboard are sent to the textfield instead of the webview, which prevents the events from being applied to the text input element of the webview. The skin of the textfield is responsible for attaching/detaching the textfield to/from the virtual keyboard: https://github.com/javafxports/openjdk-jfx/blob/develop/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TextInputControlSkin.java#L275-L288

In case of the RenderThemeImpl$FormTextField, instead of attaching itself, it should attach the webview. This is also how the virtual keyboard is managed for the webview in the HTMLEditor control: https://github.com/javafxports/openjdk-jfx/blob/develop/modules/javafx.web/src/main/java/javafx/scene/web/HTMLEditorSkin.java#L425-L436