Reviewers: jgw,

Description:
This change restores TextBoxBase's implementation of
HasChangeEventHandlers

We recently removed TextBox's implementation of HasChangeEventHandlers,
reasoning that it was redundant with its implementation of
HasValueChange<String>.

As I struggle to integrate this change with a ton of existing code that
has already sprung up relying on TextBox#addChangeHandler, in many cases
composites rethrowing the ChangeEvent, it's becoming clear that this was
a mistake.

As it stands now, TextBoxBase hides the dom event that initiated a
change. This is inconsistent with how ButtonBase propagates dom click
events, and is a loss of functionality from the old event system. Just
because our widgets "adds value" with the logical ValueChangeEvents
doesn't mean we should be trying to hide the dom events behind them.

Please review this at http://gwt-code-reviews.appspot.com/2401

Affected files:
   user/src/com/google/gwt/user/client/ui/TextBoxBase.java


Index: user/src/com/google/gwt/user/client/ui/TextBoxBase.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/TextBoxBase.java     (revision 4577)
+++ user/src/com/google/gwt/user/client/ui/TextBoxBase.java     (working copy)
@@ -19,6 +19,7 @@
  import com.google.gwt.dom.client.Element;
  import com.google.gwt.event.dom.client.ChangeEvent;
  import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.dom.client.HasChangeHandlers;
  import com.google.gwt.event.logical.shared.ValueChangeEvent;
  import com.google.gwt.event.logical.shared.ValueChangeHandler;
  import com.google.gwt.event.shared.HandlerRegistration;
@@ -31,7 +32,7 @@
   */
  @SuppressWarnings("deprecation")
  public class TextBoxBase extends FocusWidget implements  
SourcesChangeEvents,
-    HasText, HasName, HasValue<String> {
+    HasChangeHandlers, HasText, HasName, HasValue<String> {

    /**
     * Text alignment constant, used in
@@ -88,9 +89,13 @@
      super(elem);
    }

+  public HandlerRegistration addChangeHandler(ChangeHandler handler) {
+    return addDomHandler(handler, ChangeEvent.getType());
+  }
+
    @Deprecated
    public void addChangeListener(ChangeListener listener) {
-    addDomHandler(new ListenerWrapper.WrappedChangeListener(listener),  
ChangeEvent.getType());
+    addChangeHandler(new ListenerWrapper.WrappedChangeListener(listener));
    }

    public HandlerRegistration addValueChangeHandler(
@@ -98,11 +103,11 @@
      // Initialization code
      if (!valueChangeHandlerInitialized) {
        valueChangeHandlerInitialized = true;
-      addDomHandler(new ChangeHandler() {
+      addChangeHandler(new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            ValueChangeEvent.fire(TextBoxBase.this, getText());
          }
-      }, ChangeEvent.getType());
+      });
      }
      return addHandler(handler, ValueChangeEvent.getType());
    }



--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to