Fixed mouse drag support and issue where mouse events were obscured by the status panel on the bottom -- Mouse is now 100%

This commit is contained in:
Brendan Robert 2015-03-29 00:56:59 -05:00
parent 879f1516fc
commit d488932dff
3 changed files with 6 additions and 10 deletions

View File

@ -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<MouseEvent> 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<MouseEvent> handler) {
appleScreen.removeEventHandler(MouseEvent.MOUSE_MOVED, handler);
appleScreen.removeEventHandler(MouseEvent.MOUSE_PRESSED, handler);
appleScreen.removeEventHandler(MouseEvent.MOUSE_RELEASED, handler);
appleScreen.removeEventHandler(MouseEvent.ANY, handler);
}
}

View File

@ -104,11 +104,12 @@ public class CardAppleMouse extends Card {
EventHandler<MouseEvent> 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) {

View File

@ -13,7 +13,7 @@
<StackPane fx:id="stackPane" prefHeight="384.0" prefWidth="560.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<ImageView fx:id="appleScreen" fitHeight="384.0" fitWidth="560.0" pickOnBounds="true" />
<HBox fx:id="notificationBox" alignment="BOTTOM_RIGHT" blendMode="SCREEN" fillHeight="false" maxHeight="45.0" prefHeight="45.0" prefWidth="560.0" StackPane.alignment="BOTTOM_CENTER" />
<HBox fx:id="notificationBox" alignment="BOTTOM_RIGHT" blendMode="SCREEN" fillHeight="false" maxHeight="45.0" mouseTransparent="true" prefHeight="45.0" prefWidth="560.0" StackPane.alignment="BOTTOM_CENTER" />
</children>
</StackPane>
</children>