tags:

views:

34

answers:

1

Hi,

Can we add a listener for mouse move events on the main document in GWT? I'm not sure how to do this and if whatever I do add will interfere with other parts of GWT (like drag and drop?). In javascript I do this:

window.onload = function() { 
  document.onmousemove = function(e) { 
      alert("the mouse was moved!"); 
  }; 
} 

I'm just not sure where to start, GWT got a bit confusing for me since the new stuff was introduce in 2.0 (I used to use 1.4),

Thanks

+1  A: 

I'm not sure why you'd want to monitor the movement of the mouse in the whole window, but a quick and dirty solution would be to wrap everything in a FocusPanel and add a handler via addMouseMoveHandler(MouseMoveHandler handler) (check the other interfaces that FocusPanel implements - there's quite a lot of them :)). AFAICT, this shouldn't conflict with anything else (drag&drop is not part of GWT, BTW ;)) - unless you start to mess around with the event itself (like stop propagating it) or something.

Igor Klimer
Ok I can do that, thanks.