Closed GoogleCodeExporter closed 9 years ago
Original comment by gwt.team...@gmail.com
on 17 Dec 2007 at 7:01
Original comment by mmendez+personal@google.com
on 4 Mar 2008 at 9:05
Original comment by gwt.team...@gmail.com
on 6 Mar 2008 at 2:21
Aside from any other utility, we think this will be great for writing unit
tests for
event handling.
My current idea on how to implement this is to add a triggerXXX
where XXX is the name of the method inside of the appropriate listener that
will end
up firing (I just looked over the Listener classes and there won't be any name
conflicts here.)
e.g.
Marker.triggerOnDrag()
InfoWindow.triggerOnInfoWindowOpened(MapWidget sender)
Map.onZoom(MapWidget sender, int oldLevel, int newLevel);
Original comment by gwt.team...@gmail.com
on 13 Mar 2008 at 5:52
But, then, what if I want to assign arbitrary listeners and trigger arbitrary
events?
That's the beauty of the current system.
Original comment by pamela.fox
on 14 Mar 2008 at 12:01
Reply to comment #5:
Aside from just being able to do that, is there a use case where that is
necessitated? What does GEvent.trigger actually do if you try to trigger an
event
on a source object that does not support the event type that you requested?
I'm not sure how Eric's proposal would not meet the needs; at least, as we
currently
understand them. You have an object that can source events. You can add a
listener
to it, and then you trigger one of the events that the object supports.
Could you help us understand the deficiencies?
Original comment by stxmen...@gmail.com
on 19 Mar 2008 at 12:01
The GEvent.trigger and addListener system is designed so that it's easy for us
to add
new events on objects, or for people to use it for custom objects (like custom
overlays, or even non-map objects). The bottom of this page explains that-
http://econym.googlepages.com/gevent.htm
If you hard-code the events as function names, we lose the ability to use it for
arbitrary events/objects.
Sorry for delay in response, was on vacation.
Original comment by pamela.fox
on 26 Mar 2008 at 1:59
We are working on a revamp to the gwt-google-apis event wrapper that will more
closely shadow the Maps
API in terms of one Java Listener per event. That will help gwt-google-apis be
able to adapt to Maps API
changes.
In the revamp, we have a 'trigger' function that will take a specific typed
event and invoke the GEvent.trigger()
method appropriately.
I think we could add a 'CustomHandler' and 'CustomEvent' where you create the
event object with a string that
is the custom event name. You would subclass CustomEvent to create an object
that has all the parameters
you want, and then, inside of 'CustomHandler' you could cast up 'CustomEvent'
to pull your data out.
MapWidget.addCustomHandler(String eventName, CustomHandler handler);
MapWidget.trigger(CustomEvent event);
interface CustomHander {
// this is just a placeholder to allow you to subclass CustomEvent to add more arguments to the event
public class CustomEvent extends EventObject {
public CustomEvent(Object source) {
super(source);
}
}
void onCustom(CustomEvent event);
}
then, you could use it like this:
class MyCustomEvent extends CustomEvent {
Foo foo;
MyCustomEvent(MapWidget m, Foo foo) {
super(m);
this.foo = foo;
}
public Foo getFoo () { return foo; }
}
MapWidget m = new MapWidget();
m.addCustomHandler( "myEvent", new CustomHandler() {
onCustom(MyCustomEvent event) {
Foo foo = event.getFoo();
...
}
}
m.trigger("myEvent", new MyCustomEvent(m, new Foo());
Original comment by gwt.team...@gmail.com
on 26 Mar 2008 at 10:20
It looks a little painful to me, but I suppose all that's important is that it's
actually doable to trigger/listen to custom events.
Original comment by pamela.fox
on 26 Mar 2008 at 1:31
Trigger support will be in 1.1 milestone 1, but just as an internal testing
tool.
Original comment by galgwt.reviews@gmail.com
on 14 Apr 2008 at 7:40
Original comment by galgwt.reviews@gmail.com
on 2 Jun 2008 at 9:51
Original comment by galgwt.reviews@gmail.com
on 9 Jun 2008 at 11:30
Original comment by galgwt.reviews@gmail.com
on 13 Oct 2008 at 8:54
Original comment by galgwt.reviews@gmail.com
on 11 Dec 2008 at 3:08
Original comment by zundel@google.com
on 21 Dec 2009 at 1:57
Original issue reported on code.google.com by
pamela.fox
on 5 Oct 2007 at 4:17