< prev index next >
modules/javafx.swt/src/main/java/javafx/embed/swt/SWTEvents.java
Print this page
rev 10032 : 8143596: Ensure FXCanvas properly forwards SWT gesture events to its embedded scene.
Summary: Ensured SWT magnify, rotate, pan, and swipe events are properly forwarded to the embedded scene.
Reviewed-by: XXXX
@@ -24,11 +24,11 @@
*/
package javafx.embed.swt;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
+//import org.eclipse.swt.events.MouseEvent;
import java.lang.reflect.Method;
//import com.sun.glass.events.KeyEvent;
import com.sun.javafx.embed.AbstractEvents;
@@ -71,13 +71,13 @@
case 3: return AbstractEvents.MOUSEEVENT_SECONDARY_BUTTON;
}
return AbstractEvents.MOUSEEVENT_NONE_BUTTON;
}
- static int getWheelRotation(Event e) {
+ static double getWheelRotation(Event e) {
int divisor = 1;
- if ("win32".equals(SWT.getPlatform())) {
+ if ("win32".equals(SWT.getPlatform()) && e.type == SWT.MouseVerticalWheel) {
int [] linesToScroll = new int [1];
//OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, linesToScroll, 0);
try {
Class clazz = Class.forName("org.eclipse.swt.internal.win32.OS");
Method method = clazz.getDeclaredMethod("SystemParametersInfo", new Class []{int.class, int.class, int [].class, int.class});
@@ -89,16 +89,17 @@
//Fail silently
}
if (linesToScroll [0] != -1 /*OS.WHEEL_PAGESCROLL*/) {
divisor = linesToScroll [0];
}
- } else {
- if ("gtk".equals(SWT.getPlatform())) {
+ } else if ("gtk".equals(SWT.getPlatform())) {
divisor = 3;
}
+ else if ("cocoa".equals(SWT.getPlatform())) {
+ divisor = Math.abs(e.count);
}
- return -e.count / Math.max(1, divisor);
+ return e.count / (double) Math.max(1, divisor);
}
static int keyIDToEmbedKeyType(int id) {
switch (id) {
case SWT.KeyDown:
< prev index next >