From 2b19055303ec8c3e29b79662aeb832e14b69f74d Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Fri, 15 Oct 2010 08:22:22 +0200 Subject: [PATCH] Make ENTER work for 'Create Group' button The 'Create Group' button in the 'GroupListScreen' is now triggered when it has the focus and ENTER is pressed. Before this change pressing ENTER when the 'Create Group' button was focused was not creating a new group but opened the existing group which was selected in the groups table. Bug: issue 741 Change-Id: I75b9f4f129fe9bd1c180017ba299879b44d53d13 Signed-off-by: Edwin Kempin --- .../gerrit/client/admin/GroupListScreen.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/GroupListScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/GroupListScreen.java index a6b026dfef..9c51b77375 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/GroupListScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/GroupListScreen.java @@ -23,8 +23,12 @@ import com.google.gerrit.client.ui.OnEditEnabler; import com.google.gerrit.client.ui.SmallHeading; import com.google.gerrit.common.PageLinks; import com.google.gerrit.reviewdb.AccountGroup; +import com.google.gwt.event.dom.client.BlurEvent; +import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.FocusEvent; +import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; @@ -86,6 +90,25 @@ public class GroupListScreen extends AccountScreen { doCreateGroup(); } }); + addNew.addFocusHandler(new FocusHandler() { + @Override + public void onFocus(FocusEvent event) { + // unregister the keys for the 'groups' table so that pressing ENTER + // when the 'addNew' button has the focus triggers the button (if the + // keys for the 'groups' table would not be unregistered the 'addNew' + // button would not be triggered on ENTER but the group which is + // selected in the 'groups' table would be opened) + groups.setRegisterKeys(false); + } + }); + addNew.addBlurHandler(new BlurHandler() { + @Override + public void onBlur(BlurEvent event) { + // re-register the keys for the 'groups' table when the 'addNew' button + // gets blurred + groups.setRegisterKeys(true); + } + }); fp.add(addNew); add(fp);