view raw
Funnythat Funnythat - 6 months ago 42
Java Question

JavaFX MousedMoved event ignored when mouse button is held down

The event within

main.getScene().addEventFilter(MouseEvent.MOUSE_MOVED, new EventHandler<MouseEvent>() {}

is not called when the mouse button is held down, is there anyway around this? Thanks.


A mouse moved with the mouse button down is a MOUSE_DRAGGED event. So you can do:

EventHandler<MouseEvent> handler = event -> { /* ... */};
main.getScene().addEventFilter(MouseEvent.MOUSE_MOVED, handler);
main.getScene().addEventFilter(MouseEvent.MOUSE_DRAGGED, handler);