On 8 juil, 22:56, dk <dean.kar...@gmail.com> wrote:
> Hi,
>
> I am back with more Handler questions.  This is currently the most
> opaque GWT topic for me.
>
> I am building a Composite widget that will have at least a Grid and a
> Button.  The Grid will act a little like a ListBox in that one or more
> rows can be "selected".  I am not using a ListBox because I need
> formatted "Columns" of row content.
>
> The button will be enabled or disabled depending on the number of
> selected rows.  If the button is enabled then there must be at least
> one selected Grid row.  If the button is clicked then I want to fire a
> ChangeEvent.
>
> Ok, I have done a little homework and I have asked about
> ClickListeners in the past so I have some small understanding of
> ClickListeners, ChangeListeners are a different beast.
>
> I want to add a ChangeListener but I am not seeing how to fire the
> Change event.
>
> I am registering ChangeEvents by:
>
>     public HandlerRegistration addChangeHandler(ChangeHandler handler)
> {
>         return addDomHandler(handler, ChangeEvent.getType());
>     }
>
> I pulled that straight from another Discussions post.  I know that I
> could use addHandler instead of addDomHandler.  I have seen that
> addDomHandler "sinks" the event and addHandler does not.  Should I
> care if the event(s) are "sunk"?

"sinking" an event means listening to it at the DOM level. In your
case, you want to fire a "logical change" event in response to the DOM-
level "click" event of the button.

In a few words: you should only use com.google.gwt.event.dom.client.*
classes when you're doing something at the DOM level. For anything
"logical", either reuse a class from
com.google.gwt.event.logical.client.* or create your own event
+handler.

You fall in the second category; and given that ValueChangeEvent
doesn't probably fit your need (it has a "value", contrary to the DOM
ChangeEvent), you should probably copy ValueChangeEvent/
ValueChangeHandler/HasValueChangeHandlers and remove the getValue
thing (or otherwise make it fit your needs).

> When the button is clicked I want to fire a change event.  Here I lose
> it.  I am looking at using:
>
>     fireEvent(GwtEvent<ChangeEvent.getType()>);
>
> but Eclipse reports a typo on the closing ">".  I am also looking at:
>
>     ChangeEvent.fireNativeEvent(nativeEvent, this);
>
> but to what should I set "nativeEvent"?

Document.get().createChangeEvent()

> Should I use this
> "fireNativeEvent" method at all?

No, you shouldn't use com.google.gwt.event.dom.client.* classes for
"logical" events.
--~--~---------~--~----~------------~-------~--~----~
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