Is there a way to listen for mousemoves on the main document? In
javascript, I usually do this:
window.onload = function() {
document.onmousemove = function(e) {
alert("the mouse was moved!");
};
}
can we add some sort of similar listener in GWT? I'm just not sure
where to start,
Thanks
1. Create a new Class that extends Widget and implements
HasMouseMoveHandlers
2. Grab the RootPanel Element and pass that into your new Class
constructor (the one that takes an Element as a param) - this should
call setElement(Element element) with you passed in element...
You can now add MouseMove handlers to you new Widget...
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
On Jan 26, 11:08 am, Fazeel Kazi <fazzze...@gmail.com> wrote:
> Another simpler solution using EventPreview:
>
> Event.addNativePreviewHandler(new Event.NativePreviewHandler()
> {
> public void onPreviewNativeEvent(NativePreviewEvent foEvent)
> {
> switch(foEvent.getTypeInt())
> {
> case Event.ONCLICK: handleClick(foEvent); break;
> case Event.ONMOUSEOVER: handleMouseOver(foEvent); break;
> }// end switch
> }
>
> });
>
> Regards.
>
> On Tue, Jan 26, 2010 at 3:09 PM, DaveC
> <david.andrew.chap...@googlemail.com>wrote:
>
> > The way I've done it (I think is):
>
> > 1. Create a new Class that extends Widget and implements
> > HasMouseMoveHandlers
>
> > 2. Grab the RootPanel Element and pass that into your new Class
> > constructor (the one that takes an Element as a param) - this should
> > call setElement(Element element) with you passed in element...
>
> > You can now add MouseMove handlers to you new Widget...
>
> > On Jan 26, 12:49 am, markww <mar...@gmail.com> wrote:
> > > Hi,
>
> > > Is there a way to listen for mousemoves on the main document? In
> > > javascript, I usually do this:
>
> > > window.onload = function() {
> > > document.onmousemove = function(e) {
> > > alert("the mouse was moved!");
> > > };
> > > }
>
> > > can we add some sort of similar listener in GWT? I'm just not sure
> > > where to start,
>
> > > Thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
Yep - agreed - but we aren't dealing with "pure javascript" this is a
toolkit...
From the GWT class:
"Adds a Event.NativePreviewHandler that will receive all events before
they are fired to their handlers. Note that the handler will receive
all native events, including those received due to bubbling, whereas
normal event handlers only receive explicitly sunk events. "
The important bits from that paragraph are "all events before they are
fired to their handlers" and "will receive all native events,
including those received due to bubbling".
The effect I've seen is that whilst this handler is attached and
"doing something", e.g. handling a mousemove, any other *event*
handlers don't get fired e.g. animations stop working, until the mouse
has stopped moving...
What they've tried to do with GWT (from my point of view at least) is
make it like Java Swing - which, if I add a ClickListener to a Swing
Button that event doesn't get bubbled, I'd expicitly have to
"manually" fire the event on it's ancestors...(I think - I'm no swing
expert!) working with the DOM (and all its cross browser quirks) is
very different to writing a Swing App (or similar)...
+ I *think* GWT uses event delegation anyway.
Cheers,
Dave
On Jan 27, 3:28 am, Fazeel Kazi <fazzze...@gmail.com> wrote:
> Are u sure abt that? I haven't done any testing in gwt for it. If u hv done,
> please share the details since have started using this extensively in my
> project.
>
> My experience from pure javascript is that one single handler at document
> level is much better that having several handlers on various buttons and
> anchors.
>
> Thanks.
>
> On Tue, Jan 26, 2010 at 4:47 PM, DaveC
> <david.andrew.chap...@googlemail.com>wrote:
> > <google-web-toolkit%2Bunsu...@googlegroups.com<google-web-toolkit%252Buns...@googlegroups.com>