Hi there,
I've got a custom event fired by some JS code in an iframe. If I add
an event listener to the iframe via JS then the event is captured.
However I'm having difficulty capturing the same event within GWT;
indeed is it possible to capture custom events in GWT?
The event is constructed and fired in JS like so:
var event = document.createEvent("Event");
event.initEvent("hideWithMessage", true, true);
event.message = "This message to be reported.";
window.parent.document.getElementById("hatsPopup").dispatchEvent(event);
(executes within an iframe hence the window.parent.document business).
Here's how I attach my handler:
frame.addDomHandler(new HideWithMessageHandler() {
@Override
public void onHideWithMessage(String message) {
Window.alert("Yippee! " + message);
}
}, HideWithMessageEvent.getType());
The event is defined as:
public class HideWithMessageEvent extends
DomEvent<HideWithMessageHandler> {
private static final Type<HideWithMessageHandler> TYPE = new
Type<HideWithMessageHandler>(
"hideWithMessage", new HideWithMessageEvent());
public static Type<HideWithMessageHandler> getType() {
return TYPE;
}
@Override
public Type<HideWithMessageHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(HideWithMessageHandler handler) {
handler.onHideWithMessage(null);
}
}
...and the handler:
public interface HideWithMessageHandler extends EventHandler {
void onHideWithMessage(String message);
}
Incidentally if I try the same sort of thing using a clickEvent then
all is well i.e. I'm able to fire a click event at the iframe from JS
and capture it in GWT. The difficulty is with custom events.
Help and guidance very much appreciated.
Kind regards,
Christopher
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.