The soft keyboard hides when a TextInputControl loses focus. This works for most cases, but when focus moves from one TextInputControl to another, the keyboard hides and then shows itself.
Native android apps hide the keyboard when a users taps anywhere on the scene which is not a TextInputControl.
For this change, the native method `hideSoftwareKeyboard` needs to be made accessible to Scene.
A MOUSE_CLICKED event filter needs to be added to Scene and focus listeners from both TextFieldSkinAndroid and TextAreaSkinAndroid needs to be removed.
Expected change:
```
scene.addEventFilter(MouseEvent.MOUSE_CLICKED, evt -> {
if (!containsTextInputControlInHierarchy(evt.getPickResult().getIntersectedNode())) {
hideSoftwareKeyboard();
}
});
...
public static boolean containsTextInputControlInHierarchy(Node node) {
while (node != null) {
if (node instanceof TextInputControl) {
return true;
}
node = node.getParent();
}
return false;
}
```
Native android apps hide the keyboard when a users taps anywhere on the scene which is not a TextInputControl.
For this change, the native method `hideSoftwareKeyboard` needs to be made accessible to Scene.
A MOUSE_CLICKED event filter needs to be added to Scene and focus listeners from both TextFieldSkinAndroid and TextAreaSkinAndroid needs to be removed.
Expected change:
```
scene.addEventFilter(MouseEvent.MOUSE_CLICKED, evt -> {
if (!containsTextInputControlInHierarchy(evt.getPickResult().getIntersectedNode())) {
hideSoftwareKeyboard();
}
});
...
public static boolean containsTextInputControlInHierarchy(Node node) {
while (node != null) {
if (node instanceof TextInputControl) {
return true;
}
node = node.getParent();
}
return false;
}
```
- relates to
-
JDK-8245053 Keyboard doesn't show when TextInputControl has focus
- Resolved