Reputation: 379
I am refactoring a JavaFX class file to a Controller class and a FXML file. In the old JavaFX class I had to create a safety net for all mouse events by putting a rectangle at the bottom z layer so that mouse events that happen while the mouse was not on a node in the scene the code would still get all mouse events. Is there a better way in FXML?
Upvotes: 1
Views: 504
Reputation: 778
You could just add an event handler to the scene itself:
scene.addEventHandler(MouseEvent.ANY, event -> {
System.out.println(event);
});
Upvotes: 1