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.
reviewer: jlabanca
testing: ant test on linux
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@4583 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/TextBoxBase.java b/user/src/com/google/gwt/user/client/ui/TextBoxBase.java
index 9fbad0c..d143c8b 100644
--- a/user/src/com/google/gwt/user/client/ui/TextBoxBase.java
+++ b/user/src/com/google/gwt/user/client/ui/TextBoxBase.java
@@ -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());
}