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 <edwin.kempin@gmail.com>
This commit is contained in:
Edwin Kempin
2010-10-15 08:22:22 +02:00
committed by Shawn O. Pearce
parent 7b6ed691a3
commit 2b19055303

View File

@@ -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);