Hi,
with the switch of the JVM version in our project, it turned out that the default behavior of Button has changed from JavaFX 2.2 to JavaFX 8. The button action is not fired on pressing the Enter key, only on pressing space.
Sample:
public class ButtonTest extends Application
{
@Override
public void start(Stage primaryStage) throws Exception
{
Button l_button = new Button("Hit me");
l_button.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent event)
{
System.out.println("auau");
}
});
primaryStage.setScene(new Scene(l_button));
primaryStage.show();
}
public static void main(String[] args)
{
launch(args);
}
}
Run the sample Application in Java 7 with JavaFX 2.2: both pressing Enter and Space print "auau" to the console if the button is focused.
Run the sample Application in Java 8: only pressing Space prints "auau"
How can this be? Hitting a focused button on Enter is a standard behavior on Windows platforms.