GWT is a really clever piece of compiler technology!

I'm currently experimenting with HTML 5's <video/> tag and GWT. For
the most part, this was very easy to get running. But event-handling
has been a major headache.

In particular, I'm trying to add a listener to "ontimeupdate", which
is called whenever the current playback time changes. In JavaScript,
the code would look this:

    # Tested in Firefox 3.5. (Will generate tons of alerts. Be
warned.)
    var video = document.getElementsByTagName('video')[0];
    video.addEventListener("timeupdate", function (event) {
        window.alert("Time: " + video.currentTime);
    }, true);

I've defined an appropriate set of classes (TimeUpdateEvent,
TimeUpdateHandler) and added a addTimeUpdateHandler function to my
Video widget. But this isn't enough to make things work--my timeupdate
handler is never called. (Code is attached below.)

Further investigation reveals that I'm still missing quite a few
pieces:

  DOMImpl::eventGetTypeInt - I need to add an entry for "timeupdate".
  DOMImpl::sinkEvents - I need to call addEventListener
("timeupdate", ..., true).
  Event - I need to add a ONTIMEUPDATE constant.

Is there an easy way to work around this without patching my local
copy of GWT? And would it be worth either (a) making the list of
events extensible at runtime, or (b) adding a list of events taken
from the HTML 5 standard?

Thank you for such an interesting toolkit, and for any advice you can
provide on supporting custom DOM events!

Cheers,
Eric

=== begin Java code ===

public class Video extends FocusWidget {
    // ... lots of code removed
    public HandlerRegistration addTimeUpdateHandler(TimeUpdateHandler
handler) {
        return addHandler(handler, TimeUpdateEvent.getType());
    }
}

public interface TimeUpdateHandler extends EventHandler {
        void onTimeUpdate(TimeUpdateEvent event);
}

public class TimeUpdateEvent extends DomEvent<TimeUpdateHandler> {

        private static final Type<TimeUpdateHandler> TYPE =
                new Type<TimeUpdateHandler>("timeupdate", new 
TimeUpdateEvent());

        public static Type<TimeUpdateHandler> getType() {
                return TYPE;
        }

        @Override
        public Type<TimeUpdateHandler> getAssociatedType() {
                return TYPE;
        }

        @Override
        protected void dispatch(TimeUpdateHandler handler) {
                handler.onTimeUpdate(this);
        }
}


--~--~---------~--~----~------------~-------~--~----~
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-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to