0

In Android, to have the keyboard be numeric only, you only need to set the inputType as number. In Javafx, you must make sure you have the correct properties set, in this case,

System.setProperty("com.sun.javafx.isEmbedded", "true");
System.setProperty("com.sun.javafx.virtualKeyboard", "javafx");

and then you set textfield.getProperties().put("vkType", "numeric");

This is not working for me at all. I have tried to add it in Gradle build, which did not work.

I have tried adding it in the init method, as below.

@Override
public void init() {
    System.setProperty("com.sun.javafx.isEmbedded", "true");
    System.setProperty("com.sun.javafx.virtualKeyboard", "javafx");
    addViewFactory(HOME_SCREEN_VIEW, () -> new HomeView().getView());
    addViewFactory(STATION_LIST_VIEW, () -> new StationListView().getView());
    addViewFactory(STATION_VIEW, () -> new StationView().getView());
    addViewFactory(CHOOSE_FLIGHT_VIEW, () -> new ChooseFlightView().getView());
    addViewFactory(SETTINGS_VIEW, () -> new SettingsView().getView());
    addViewFactory(LOGIN_VIEW, () -> new LoginView().getView());
    addViewFactory(EDIT_PREF_VIEW, () -> new EditingPrefView().getView());
    addViewFactory(SPLASH_VIEW,() -> new SplashView().getView());
    addViewFactory(OVERLOAD_VIEW, () -> new OverloadView().getView());
    addViewFactory(ADDUSER_VIEW, () -> new AddUserView().getView());
}

It also did not work. I have looked into the .apk and I found a javafx.platform.properties. file, which has android.com.sun.javafx.isEmbedded=true in it. If I change the properties to add in the android., it still does not work.

How can I make this work? I am using a normal JavaFx TextField, not Gluon TextField.

If at all possible, I would actually prefer to use the native Android numeric keyboard, but I haven't found any way to do that either.

Thanks for the help.

Hypnic Jerk
  • 1,192
  • 3
  • 14
  • 32

1 Answers1

0

I am currently working on a Gluon Android app. My solution is not ideal but this is how I circled around it! I created a GridPane once the textfield was clicked. for example textField.setOnMouseClicked(event -> { numericKeypad(); }); and my numericKeypad method contains a gridpane with buttons (with numeric text on it) and styles of the gridpane and buttons. at the end of the method I used this view.setBottom(gridPane); which sets the bottom to keyPad when you click on the textfield! and I after they are done editing I setview.setBottom(null); so that it gives it the feeling of a keyboard popping from the bottom as a regular keyboard. As I said this is not ideal or what you are looking for exactly but I hope this helps!