We know that in JavaFX the MOUSE_MOVED event is fired when the cursor moves on an EventTarget. In this case, the node stands still and the cursor moves.
Now, consider this: We have a ScrollPane and there are some small nodes in it. We let the cursor stay still, and scroll the wheel to scroll the pane. Then a node appears under the cursor. In this case, we will not get the MOUSE_MOVED event while the node passes under the cursor.
For example:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class HelloApplication extends Application {
@Override
public void start(Stage stage) {
Circle circle = new Circle(20.0);
Canvas canvas = new Canvas(400, 400); // Make the StackPane large enough
StackPane root = new StackPane();
ScrollPane pane = new ScrollPane();
circle.setFill(Color.RED);
circle.setLayoutX(200);
circle.setLayoutY(200);
canvas.setMouseTransparent(true);
root.getChildren().addAll(circle, canvas);
pane.setContent(root);
circle.setOnMouseEntered(e -> System.out.println("entered"));
circle.setOnMouseMoved(e -> System.out.println("moved"));
circle.setOnMouseExited(e -> System.out.println("exited"));
Scene scene = new Scene(pane, 420, 200);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
There is a Circle in a ScrollPane. If we let the cursor pass the circle, we will get
entered
moved
moved
...
exited
But if we posit the cursor in the width centre of the scene, above the circle, and use the wheel to scroll to let the circle pass the cursor. We will get
entered
exited
There are no MOUSE_MOVED events.
What I want is to find a type of event that could represent the missing part of the pass-through.