diff --git a/src/main/java/jace/JaceUIController.java b/src/main/java/jace/JaceUIController.java index 4ef6e04..b7519ea 100644 --- a/src/main/java/jace/JaceUIController.java +++ b/src/main/java/jace/JaceUIController.java @@ -30,7 +30,6 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import javafx.event.EventHandler; -import javafx.event.EventType; import javafx.fxml.FXML; import javafx.geometry.Insets; import javafx.scene.control.Label; @@ -223,14 +222,10 @@ public class JaceUIController { } public void addMouseListener(EventHandler handler) { - appleScreen.addEventHandler(MouseEvent.MOUSE_MOVED, handler); - appleScreen.addEventHandler(MouseEvent.MOUSE_PRESSED, handler); - appleScreen.addEventHandler(MouseEvent.MOUSE_RELEASED, handler); + appleScreen.addEventHandler(MouseEvent.ANY, handler); } public void removeMouseListener(EventHandler handler) { - appleScreen.removeEventHandler(MouseEvent.MOUSE_MOVED, handler); - appleScreen.removeEventHandler(MouseEvent.MOUSE_PRESSED, handler); - appleScreen.removeEventHandler(MouseEvent.MOUSE_RELEASED, handler); + appleScreen.removeEventHandler(MouseEvent.ANY, handler); } } diff --git a/src/main/java/jace/hardware/CardAppleMouse.java b/src/main/java/jace/hardware/CardAppleMouse.java index 90b5380..18af85c 100644 --- a/src/main/java/jace/hardware/CardAppleMouse.java +++ b/src/main/java/jace/hardware/CardAppleMouse.java @@ -104,11 +104,12 @@ public class CardAppleMouse extends Card { EventHandler mouseHandler = this::processMouseEvent; private void processMouseEvent(MouseEvent event) { - if (event.getEventType() == MouseEvent.MOUSE_MOVED) { + if (event.getEventType() == MouseEvent.MOUSE_MOVED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) { Node source = (Node) event.getSource(); updateLocation(event.getSceneX(), event.getSceneY(), source.getBoundsInLocal()); event.consume(); - } else if (event.getEventType() == MouseEvent.MOUSE_PRESSED) { + } + if (event.getEventType() == MouseEvent.MOUSE_PRESSED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) { mousePressed(event); event.consume(); } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) { diff --git a/src/main/resources/fxml/JaceUI.fxml b/src/main/resources/fxml/JaceUI.fxml index 568ce04..11b09e6 100644 --- a/src/main/resources/fxml/JaceUI.fxml +++ b/src/main/resources/fxml/JaceUI.fxml @@ -13,7 +13,7 @@ - +