There is an issue posted for adding a keyboard listener to the
document here:
http://code.google.com/p/google-web-toolkit/issues/detail?id=1442
Based on the GWT team response to that issue, I would assume that
there is not going to mouse listener support for the entire document
anytime soon.
Whenever something doesn't have a good api yet in GWT, you can always
roll your own with JSNI. Something like this would be my approach:
public class MousePosition {
public static int x,y;
private static MouseMoveEvent mouseEvent; //from
com.google.gwt.event.dom.client.MouseMoveEvent
public static void setMouseEvent(MouseMoveEvent e){
mouseEvent = e;
x = mouseEvent.getX();
y = mouseEvent.getY();
sliqueJS.log.info("latest mouse event position (X,Y) = "+x
+","+y);
}
public static native void trackMousePos() /*-{
$wnd.document.onmousemove =
@com.slique.input.MousePosition::setMouseEvent(Lcom/google/gwt/event/
dom/client/MouseMoveEvent;);
}-*/;
}
Unfortunately, code is spewing an error I don't recognize. Can anyone
else tell what's going on here?
java.lang.IllegalArgumentException
at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod
(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.MethodDispatch.invoke
(MethodDispatch.java:97)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke
(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6
(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6
(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents
(SwtHostedModeBase.java:297)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop
(HostedModeBase.java:565)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:411)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:243)
~Carver
http://slique.com - builds group memory by putting all your group's
email, files and documents in one place