Re: custom event + event bubbling

2011-06-27 Thread Ashwin Desikan
You should be able to bubble custom events using the attachHandler and 
fireEvents method on a widget. 

I am still trying to conceive an example where you would need a custom event. 
Most of the widely used events for all widgets have handlers defined. 

I have not personally tried attaching a custom handlers to a widget but have 
created custom widgets by extending existing widgets like Cell where you can 
specify the events you want to listen on. 

~ashwin  

Sent from my iPhone

On Jun 27, 2011, at 3:47 AM, isern juanis...@gmail.com wrote:

 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.
 

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



Re: custom event + event bubbling

2011-06-26 Thread isern
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.



Re: custom event + event bubbling

2011-06-25 Thread Ashwin Desikan
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 view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/caEzUtD8HKsJ.
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.



Re: custom event + event bubbling

2011-06-25 Thread isern
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.



Re: custom event + event bubbling

2011-06-25 Thread ashwin.desi...@gmail.com
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.



custom event + event bubbling

2011-06-24 Thread isern
Hello,

I was wondering, is it possible to bubble up a custom event through
the widget hierarchy?

The EventBus solution seems great but in some cases I'd like to catch
certain events related to the current context that's usually given
by the UI.

Thanks..!

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