Robot and keyPress

前端 未结 1 1280
时光取名叫无心
时光取名叫无心 2021-01-15 09:22

What sort of code need to be passed to the JavaFX Robot when using the keyPress method?

For example, the example below enters a 1, not an <

相关标签:
1条回答
  • Codes are defined as constants in javafx.scene.input.KeyCode.

    With the glass robot, you can use the deprecated method impl_getCode:

    Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();
    robot.keyPress(KeyCode.A.impl_getCode());
    

    You can also use the FXRobot, which takes KeyCodes as parameters:

    FXRobot robot = FXRobotFactory.createRobot(scene);
    robot.keyPress(javafx.scene.input.KeyCode.A);
    
    0 讨论(0)
提交回复
热议问题