In the @UIHandler example, you have a direct reference to the button and you register a handler directly on the event source.
I was wondering if there's the possibility that some custom event goes up in the UI hierarchy. To illustrate, in this situation I could perfectly bind a handler to the widget that contains those buttons, and I still catch the click event because of the principle of event bubbling, that's the default behavior in JS DOM events. Now my question was if I can use event bubbling with custom events created by me. On Jun 26, 2:40 am, "ashwin.desi...@gmail.com" <ashwin.desi...@gmail.com> wrote: > for listening on events on your widget you can define UiHandler or Attach / > Add handlers > > for example, if you have a button defined in your UIBinder > > <g:Button ui:field = 'button1'>Hello</g:Button> > > now if you want to listen on click event of this button, you can do either > of these two operations > > @UiHandler("button1") > public void OnButton1Click(ClickEvent event) { > ///do what ever you want on button click > > } > > when you are not using a UiBinder you can define > > button1.addClickHandler(new ClickHandler() { > @Override > public void onClick(ClickEvent arg0) { > //do your opertaions > > } > }) > > hope this is clear. > > Thanks > Ashwin > > On Sun, Jun 26, 2011 at 4:40 AM, isern <juanis...@gmail.com> wrote: > > I come from the Flex/JS/Tapestry worlds and a technique commonly used > > is to attach listeners to certain events expecting they'll will go up > > like a bubble through the component hierarchy. Actually if I'm not > > wrong this kind of behavior also occurs with native hardware events in > > GWT. > > > A typical example is the Accept/Cancel widget. It's a widget because > > it's repeated all over the application. > > > To reduce coupling to a minimum, I'd like to listen to the events > > "accept" and "cancel" on the current widget (that contains accept/ > > cancel directly or indirectly), being aware that if users click > > "accept" the event will be caught and what you do depends on that > > context (UI structure) > > > The EventBus is okay, but it doesn't seem to take into account this > > component hierarchy, all the event handlers are notified without > > discrimination. > > > I've managed, however, to create a BubbledEvent/BubbledEventHandler > > that only is dispatched if the current listener (a visual widget) is a > > parent of that which triggered it. > > > I hope I was clear, > > > Best regards, Juan > > > On Jun 25, 3:34 am, Ashwin Desikan <ashwin.desi...@gmail.com> wrote: > > > what sort of events are you looking to capture? You can create custom > > events > > > and register those events with the eventBus. When ever that event occurs > > all > > > handlers would receive a notification and you can take necessary action. > > > > Thanks > > > Ashwin > > > -- > > 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. -- 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.