Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows tablet touch keyboard doesn't popup when textfield focused

When focus is gained into a TextField, the touch screen keyboard doesn't appear.

I suppose it's because a JavaFx Application isn't Metro compliant?

I find a way to pop up the keyboard:

public class Controller {

   public static void showVirtualKeyboard(
      ObservableValue<? extends Boolean> observable,
      Boolean                            oldState,
      Boolean                            hasFocus )
   {
      if( hasFocus ) {
         try {
            Runtime.getRuntime().exec(
               "cmd /c \"C:\\Program Files\\Common Files\\microsoft " +
               "shared\\ink\\tabtip.exe\"" );
         }
         catch( final Throwable t ) {
            LogHelper.severe( t );
         }
      }
   }
}

In any view:

final class VisualAnalysis extends GridPane implements IView {

   private final TextField tech = new TextField();

   @Override
   public void setController( Controller ctrl   ) {
      ...
      tech.focusedProperty().addListener( Controller::showVirtualKeyboard );
   }

It's a workaround. Have you discover a better way?

like image 955
Aubin Avatar asked Oct 31 '22 17:10

Aubin


1 Answers

This is a cool way to show the Windows native virtual keyboard (which I feel is much better than the JavaFX one).

Have you run the application with with the VM arguments

-Dcom.sun.javafx.isEmbedded=true
-Dcom.sun.javafx.virtualKeyboard=javafx

The last one should also take the parameter 'native' but it also shows the JavaFX keyboard for me. So for explicitly showing the Windows keyboard I'm looking for some help myself :)

like image 66
terix2k11 Avatar answered Nov 09 '22 01:11

terix2k11