Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
Fix for macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
brcolow committed Nov 28, 2018
1 parent 6765708 commit 993f4fa
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private static void testMouseAction(MouseAction mouseAction, MouseButton mouseBu
InvalidationListener invalidationListener = observable -> setSceneLatch.countDown();
String expectedText = mouseAction + " " + mouseButton;
Util.runAndWait(() -> {
MouseActionHandler mouseActionHandler = new MouseActionHandler(button, mouseAction, mouseButton, onClickLatch);
MouseActionHandler mouseActionHandler = new MouseActionHandler(button, mouseAction, mouseButton, onClickLatch);
switch (mouseAction) {
case PRESSED:
button.setOnMousePressed(mouseActionHandler);
Expand Down Expand Up @@ -474,12 +474,10 @@ private static void testMouseWheel(int amount) {
InvalidationListener invalidationListener = observable -> setSceneLatch.countDown();
int[] totalScroll = new int[]{0};
long[] firstScrollMillis = new long[]{0};
int scrollMultiplier = System.getProperty("os.name").toLowerCase().startsWith("mac") ? -1 : 40;
Util.runAndWait(() -> {
button.setOnScroll(event -> {
System.out.println("event: " + event);
System.out.println("total scroll before: " + totalScroll[0]);
totalScroll[0] += event.getDeltaY();
System.out.println("total scroll after: " + totalScroll[0]);
if (firstScrollMillis[0] == 0) {
firstScrollMillis[0] = System.currentTimeMillis();
} else {
Expand All @@ -488,9 +486,8 @@ private static void testMouseWheel(int amount) {
onScrollLatch.countDown();
}
}
if (Math.abs(totalScroll[0]) / 40 >= Math.abs(amount)) {
System.out.println("total scroll is greater than or equal to amount");
button.setText("Scrolled " + -(totalScroll[0] / 40));
if (Math.abs(totalScroll[0] / scrollMultiplier) >= Math.abs(amount)) {
button.setText("Scrolled " + -(totalScroll[0] / scrollMultiplier));
onScrollLatch.countDown();
}
});
Expand Down Expand Up @@ -747,4 +744,4 @@ private static String colorToString(Color c) {
private static String capFirst(String str) {
return Character.toUpperCase(str.charAt(0)) + str.substring(1).toLowerCase();
}
}
}

0 comments on commit 993f4fa

Please sign in to comment.