Skip to content

Commit

Permalink
Test scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack253-png committed Sep 20, 2024
1 parent dee17f8 commit eba86fb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public final class FlutterNative {

public static native void sendMetricsEvent(long instance, int width, int height, long view);

public static native void sendScrollEvent(long instance, double x, double y, double xAmount, double yAmount, long view);

public static native void pollEvents(long instance);

public static native int getTexture(long instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ object MouseEvent {
return false
}

fun onMouseScroll(x: Double, y: Double, amount: Double): Boolean {
fun onMouseScroll(x: Double, y: Double, xAmount: Double, yAmount: Double): Boolean {
for (i in instances) {
if (i.hitTest(x, y)) {
FlutterNative.sendScrollEvent(i.handle, x, y, xAmount, yAmount, 0)
return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ private void onMouseScroll(long window, double xOffset, double yOffset, Callback
double[] x = {0};
double[] y = {0};
glfwGetCursorPos(window, x, y);
System.out.println(xOffset + " " + yOffset + " " + x[0] + " " + y[0]);
if (MouseEvent.INSTANCE.onMouseScroll(x[0], y[0], yOffset)) ci.cancel();

if (MouseEvent.INSTANCE.onMouseScroll(x[0], y[0], xOffset, yOffset)) ci.cancel();
}
}

0 comments on commit eba86fb

Please sign in to comment.