MouseMove events (while mouse button down) not transmitted in all cases

79 views
Skip to first unread message

James Lamanna

unread,
Sep 15, 2010, 5:40:03 PM9/15/10
to KML Developer Support - Google Earth Plug-in
Hi,
I've noticed that if you attach an event handler to the 'mousemove'
event of say GEGlobe, you do not get any mouse events while holding a
mousebutton down _unless_ you call preventDefault() in the mousedown
event.

This problem only seems to manifest itself when you are only over the
globe. If you are over placemarks, then it seems to work how it should
(mousemove events come through).

You can see this behavior if you take the example of drag drop:
http://earth-api-samples.googlecode.com/svn/trunk/examples/placemark-dragdrop.html

And then at the top of the 'mousemove' eventhandler (outside of if
(dragInfo)), add something like:

if (event.getButton() == 0) { alert('left button down'); }

You'll see you only see this alert if you are on the placemark, and
not if you are dragging elsewhere in the window.

fraser (Earth API Guru)

unread,
Sep 27, 2010, 12:35:45 PM9/27/10
to KML Developer Support - Google Earth Plug-in
Hi,

This could be due to a couple of things.

Firstly, the kmlEvent doesn't contain the method 'getButton' only the
KmlMouseEvent does.
Secondly, the alert function can cause issues as it effectively pauses
the script execution.

With that in mind you could try the following to see if it resolves
the issue.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
if(event.getType() == 'KmlMouseEvent') {
if (event.getButton() == 0) { //left mouse
document.getElementById('output').innerHtml = 'left button down';
}
}

...
<div id='output'>...</div>
----------------------------------------------------------------------------------------------------------------------------------------------------------------

F.

On Sep 15, 10:40 pm, James Lamanna wrote:
> Hi,
> I've noticed that if you attach an event handler to the 'mousemove'
> event of say GEGlobe, you do not get any mouse events while holding a
> mousebutton down _unless_ you call preventDefault() in the mousedown
> event.
>
> This problem only seems to manifest itself when you are only over the
> globe. If you are over placemarks, then it seems to work how it should
> (mousemove events come through).
>
> You can see this behavior if you take the example of drag drop:http://earth-api-samples.googlecode.com/svn/trunk/examples/placemark-...

James Lamanna

unread,
Sep 28, 2010, 5:16:59 PM9/28/10
to KML Developer Support - Google Earth Plug-in
Hi Fraser,
I tried also setting text in a DIV, and I get the same behavior.
I only receive the events when I'm dragging the placemark, not when
I'm dragging the globe.

-- James
Reply all
Reply to author
Forward
0 new messages