sounds reasonable, thanks. But it seems like the Widget is indeed capable of firing "anonymous" events, because of the public fireEvent() method defined in the HasHandlers interface - so its a little confusing if I can fire any event from external code on a Widget but can only add handlers for customized events in its subclasses, I think the contract between fireEvent() and addEventHandler() would match if both were protected or public.
In my usecase I would be able fire a WidgetScannedEvent() from external code (WidgetScanner) ( due to the public fireEvent() on the Widget ) regardless if its a Button, a Label or a TextBox, but unfortunately I cannot handle that event at a Widget level. On 10 Nov., 16:41, Joel Webber <j...@google.com> wrote: > The point of that method being protected is that under normal circumstances > you don't want to be able to add handlers to a widget that's not capable of > firing them in the first place. So a widget subclass creates > addFooHandler(), then uses this method internally. > > Are you saying you want to add a custom event handler to a widget, then > force that widget to fire the event from external code? Sounds like it wants > to be a subclass. > > Le 9 novembre 2010 01:56, cokol <eplisc...@googlemail.com> a écrit : > > > why is com.google.gwt.user.client.ui.Widget.addHandler(H, Type<H>) > > protected? in case I want to fire a custom event on a widget so that > > the widget is not aware of custom event handler, it makes it difficult > > to manage. > > > thanks > > > -- > >http://groups.google.com/group/Google-Web-Toolkit-Contributors -- http://groups.google.com/group/Google-Web-Toolkit-Contributors