GarryNewman
GarryNewman

Reputation: 81

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.

Upvotes: 3

Views: 212

Answers (2)

James_D
James_D

Reputation: 209339

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);

Upvotes: 4

L. Carbonne
L. Carbonne

Reputation: 481

You have to use this move event when the mouse is pressed :

MOUSE_DRAGGED

Upvotes: 1

Related Questions