The GWT event model is a close relation of the standard Java event model.

The problem with the standard DOM EventListeners is that only one listener can 
be attached to an 
Element. The other problem is that a custom Widget may be required to listen 
for a sequence of 
low-level events in order to trigger a single high-level event (think 
MOUSEDOWN/UP/MOVE in relation 
to itemDraggedAndDropped()).

So you hide the low-level events within Widget classes, which when they receive 
the event can 
trigger the collection of ClickListeners / MouseListeners / 
MyFancyListenerNumber3.

If you are extending the classes over and over again, adding your 
"double-click" behavior to each 
one in it's onBrowserEvent method, you're doing it wrong. The correct way is to 
extend once, and 
allow for adding any additional listeners (double-click, keyboard, etc.) to the 
extended class 
(which should trigger them in it's onBrowserEvent method). This way the event 
handling logic remains 
separated from the Widget itself.

Also bare in mind Composite style classes (like a TabPanel) that want to turn a 
Click event on a tab 
into onBeforeTabSelected and onTabSelected for it's TabListeners.

Hope that helps a bit.

David H. Cook wrote:
> 
> The more code I implement and the more event-related APIs
> I look at in GWT, the more confused I get.  After
> looking at complete examples about 'listeners' on website such as:
> http://examples.roughian.com/index.htm#Listeners~Summary
> or posts in this group, I conclude that the most general
> is an 'EventListener', because then I can get at ANY/ALL events
> that I might be interested in, as it's method gets 'Event e'
> as an input param.  But, what seems to me like
> a real NEGATIVE is that I must 'extend' (sub-class) an object
> to use EventListener, right?
> 
> Now, if I only care about a 'click', then I do NOT need to extend,
> because there are 'clicklisteners', which listen for just ONE event
> type...'click'.  But, if I want, say, 'double-click', well, there
> are NOT any 'double-click' listeners, so it seems that I'll need
> to use the more general EventListener.
> 
> That would be reasonable/acceptable if there was just
> ONE object that I wanted/needed to extend in a given app.
> But, let's say, I care about 'doubleclicks' from 3 different
> objects in the same app...anchors, tabs, and images.
> (Maybe not the best examples, but bear with me.)
> So, it seems that now I need to extend three objects, so I'll
> need 3 java classes (and thus, ...3 FILES...one class per file).
> [Some posts/examples mention 'widget builders'  as a separate
> class of developer.  But, I don't want to build new 'widgets'...
> I just want a write a simple app.
> 
> Somehow, the APIs seem to be making things unnecessarily 'complex',
> when I compare this to how easy it was to implement events
> in javascript language (before I started using GWT).  And, its
> beginning to seem like the designers of the event-model/event-apis in
> GWT
> might have miss-designed the APIs?!  (I wasn't around at the
> beginning, so I don't know how the event-APIs looked in version 1.00.)
> 
> Both the author of roughian website and other posters all seem to
> bemoan
> this need to extend, but all say it is necessary.  For example,
> roughian
> says:
> 
> [Notes:
> This is something you should only use if you are subclassing a widget
> - it's not much use otherwise,
> you can't addEventListener() to anything I'm aware of.
> So, as a builder of widgets, you'd use this to pick up events and use
> them in ways
> that you can't do with the ordinarily supported event interfaces]
> 
> Clearly, I (and others?) must all be missing something.  Where have I
> gone wrong?
> 
> > 
> 

--~--~---------~--~----~------------~-------~--~----~
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