-
Bug
-
Resolution: Fixed
-
P4
-
8
-
Windows 7 64bit
Java 8.0b129
Run the following and observe the events that are processed when typing various keys.
PrintScreen appears to be unique in that it only produces a KEY_RELEASED event.
package listviewkeytyped;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class ListViewKeyTyped extends Application {
private final EventHandler<? super KeyEvent> logEvent = new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent t) { System.out.println("got: "+t); }
};
@Override
public void start(Stage primaryStage) {
Label label = new Label("Focus me and type...");
label.setFocusTraversable(true);
label.setMaxSize(300,250);
label.addEventFilter(KeyEvent.ANY, logEvent);
StackPane root = new StackPane();
root.getChildren().add(label);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("KeyEvents dumped to stdout");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) { launch(args); }
}
PrintScreen appears to be unique in that it only produces a KEY_RELEASED event.
package listviewkeytyped;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class ListViewKeyTyped extends Application {
private final EventHandler<? super KeyEvent> logEvent = new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent t) { System.out.println("got: "+t); }
};
@Override
public void start(Stage primaryStage) {
Label label = new Label("Focus me and type...");
label.setFocusTraversable(true);
label.setMaxSize(300,250);
label.addEventFilter(KeyEvent.ANY, logEvent);
StackPane root = new StackPane();
root.getChildren().add(label);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("KeyEvents dumped to stdout");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) { launch(args); }
}