songjingyu / winforms-geplugin-control-library

Automatically exported from code.google.com/p/winforms-geplugin-control-library
0 stars 0 forks source link

Add/Remove eventlistners on Globe #105

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. _geWb.AddEventListener(_ge.getGlobe(), EventId.Click);
2. Capture input from user...
3. when done _geWb.RemoveEventListener(_ge.getGlobe(), EventId.Click);

From the output window I mostly get the following and don't got any problems:
GEWebBrowser: InvokeJavascript: jsAddEventListener( System.__ComObject, 
23029828, CLICK, , False )
The thread '<No Name>' (0xc9c) has exited with code 0 (0x0).
GEWebBrowser: InvokeJavascript: jsRemoveEventListener( System.__ComObject, 
23029828, CLICK, False )

BUT sometimes the event id changes:
GEWebBrowser: InvokeJavascript: jsAddEventListener( System.__ComObject, 
9961553, CLICK, , False )
The thread '<No Name>' (0x21bc) has exited with code 0 (0x0).
GEWebBrowser: InvokeJavascript: jsRemoveEventListener( System.__ComObject, 
61101387, CLICK, False )

In these cases the event isn't removed as expected.

What is the expected output? What do you see instead?
The event is removed - It isn't

What version of the product are you using? On what operating system?
r513, win7

Original issue reported on code.google.com by tho...@gmail.com on 17 May 2013 at 9:28

GoogleCodeExporter commented 9 years ago
Thanks for this, I will take a look and see if I can reproduce it.
OOI are you always passing in "_ge.getGlobe()" or are you perhaps using a 
variable to hold a reference to the globe?

Thanks,

Fraser

Original comment by fraser.c...@gmail.com on 17 May 2013 at 10:09

GoogleCodeExporter commented 9 years ago
Hi again,

yes I'm always passing "_ge.getGlobe()".

I've tried to store geGlobe in a var when the plugin is ready and using the var 
adding/removing the events - And I haven't been able to reproduce the error yet.
/TKM

Original comment by tho...@gmail.com on 17 May 2013 at 11:29

GoogleCodeExporter commented 9 years ago
Hey,

Thanks for getting back to me - unfortunately I can't seem to reproduce the 
error - although I will keep an eye on it and leave this issue open for now...

Original comment by fraser.c...@gmail.com on 17 May 2013 at 10:53

GoogleCodeExporter commented 9 years ago

Original comment by fraser.c...@gmail.com on 18 Jul 2013 at 1:46

GoogleCodeExporter commented 9 years ago
Hi Fraser,
I've noticed that when adding the click event to the globe, all existing 
placemarks(added with no event) "gets" the click event. 

I can then click the placemarks and the _geWb_KmlEvent(object sender, 
GEEventArgs e) is fired.(eventType: Click, Message: KmlMouseEvent, mapObject: 
KmlPlacemark).
Is this to be expected?

/TKM

Original comment by tho...@gmail.com on 3 Sep 2013 at 12:35

GoogleCodeExporter commented 9 years ago
Hi,

Yes, if you are "adding the click event to the globe" and then all clicks will 
be captured. That is how the API works.

If you want specific placemarks to have specific events then you would need to 
either 

a) screen the objects in a generic globe click handler and act accordingly for 
placemarks. 

geWebBrowser1.AddEventListener(ge.getGlobe(), EventId.Click);
geWebBrowser1.KmlEvent += (o, e) =>
{
  // screen for the objects here 
}

b) attach specific handlers to specific objects

geWebBrowser1.AddEventListener(myPlacemark, EventId.Click);
geWebBrowser1.KmlEvent += (o, e) =>
{
  // handle myPlacemark click
}

Original comment by fraser.c...@gmail.com on 5 Sep 2013 at 3:33

GoogleCodeExporter commented 9 years ago
Thanks for clarifying that. I was under the impression that:
geWebBrowser1.AddEventListener(ge.getGlobe(), EventId.Click); only would add a 
surface click.

Original comment by tho...@gmail.com on 13 Sep 2013 at 12:31

GoogleCodeExporter commented 9 years ago
Well strictly speaking it does. It is just that if a placemark is on the globe 
then it's click event is also triggered as a target in the capturing phase.

Just to note you can also control the capturing/bubbling behavior if required 
using the optional `setCapture` parameter on AddEventListener.

If you are not sure about capturing/bubbling then this should help 
http://www.quirksmode.org/js/events_order.html

Original comment by fraser.c...@gmail.com on 14 Sep 2013 at 5:06