Reputation: 131
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.
Upvotes: 1
Views: 567
Reputation: 45476
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.
Upvotes: 1