Replace TextSaveButtonListener use with new OnEditEnabler.

The TextSaveButtonListener class was used to enable a button
by listening to keystrokes to determine whether actual text
had been entered in the field or not.  This is used to enable
save buttons in forms.  The method used to detect changes was
very efficient, but it failed to catch CTRL-V pasting in
Chrome and X11 middle button pasting in FF and Chrome.

Replace the uses of TextSaveButtonListener with a new
OnEditEnabler class.  This class is designed to listen to
several input widgets types, ListBoxes and CheckBoxes, not
just textboxes, making them also able to enable the
FocusWidget.  This class can easily be extended to handle
other types of input widgets if neccessary.  Instead of just
listening to keystrokes from textboxes, OnEditEnabler
registers a listener for key press, key down, and mouse up.
On receipt of those events, it compares the new text against
the old text (the text before getting focus) to determine if
any of the events have actually changed the  text. This seems
able to capture text changes more reliably.

Change-Id: I285cea25e3ef3d076def06f240bf678857595ae3
This commit is contained in:
Martin Fick
2010-09-21 08:23:07 -06:00
committed by Shawn O. Pearce
parent e3febd9e54
commit 6f5d33e7c1
8 changed files with 196 additions and 121 deletions

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.client.account;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.TextSaveButtonListener;
import com.google.gerrit.client.ui.OnEditEnabler;
import com.google.gerrit.common.errors.InvalidUserNameException;
import com.google.gerrit.reviewdb.Account;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -73,7 +73,7 @@ class UsernameField extends Composite {
doSetUserName();
}
});
new TextSaveButtonListener(userNameTxt, setUserName);
new OnEditEnabler(setUserName, userNameTxt);
userNameLbl.setVisible(false);
body.add(userNameLbl);