1

I have enabled JavaFX virtual keyboard on desktop application (by passing the virtual machine arguments). But while porting to android application using JavaFXPorts then the JavaFX virtual keyboard not visible in android, that shows android's native keyboard. And I tried to pass jvm arguments via comment line (while run the gdradlew android), but it not working. And also I tried invoke the FXVK.init(textField); FXVK.attach(textField); methods while the text field was focused. But these are not showing JavaFX virtual keyboard, its shows only android native keyboard.

Ashok Kumar
  • 131
  • 1
  • 11

1 Answers1

1

Using JavaFXPorts on Android, if you try to print out:

Platform.isSupported(ConditionalFeature.VIRTUAL_KEYBOARD)

The result will be false.

And the reason for that can be found as follows:

  • Platform calls Toolkit.getToolkit().isSupported(), that goes to the QuantumToolkit, which ends up calling Application.GetApplication().hasVirtualKeyboard().

  • The application for Android is MonocleApplication, and hasVirtualKeyboard returns false:

    @Override
    public boolean hasVirtualKeyboard() {
        return deviceFlags[DEVICE_PC_KEYBOARD] == 0 && 
               deviceFlags[DEVICE_TOUCH] > 0;
    }
    

While touch is supported and the second condition is true, the first condition fails, because device.isFullKeyboard() returns true. device is an instance of InputDevice, which on Android is implemented by AndroidInputDevice.

And we finally get to AndroidInputDevice::isFullKeyboard, that returns true and makes the above condition false.

And we can see a comment that explains how this could be changed:

@Override
public boolean isFullKeyboard() {
    // if we return false, the JavaFX virtual keyboard will be used 
    // instead of the android built-in one
    return true;
}

If you modify that line, and build JavaFXPorts, you will have support for the JavaFX keyboard. But given the limitations of that keyboard, I'm not sure why you would want to use it over the native one.

José Pereda
  • 39,900
  • 6
  • 84
  • 114
  • My application run on portrait mode. When I click the text field then the native keyboard popup and covers half of the screen (then keyboard hide the next input field). I need to overcome this issue. Or how can I customise android native keyboard. Please tell me what are the limitations of JavaFX virtual keyboard. – Ashok Kumar Oct 08 '18 at 10:03
  • 1
    That issue is fixed with Gluon Mobile. But if you want to fix it yourself have a look at this [answer](https://stackoverflow.com/a/36345464/3956070), or this other [one](https://stackoverflow.com/a/41526346/3956070). About keyboards, there is no possible comparison with the native one. Your users wouldn't expect a different keyboard. The JavaFX one is not customizable (language, buttons, ...) – José Pereda Oct 08 '18 at 10:18