Support enter to submit on most forms
Bug: issue 456 Change-Id: Iee35db202817baf4efd7757a593b763fbbff6e26 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -28,6 +28,9 @@ import com.google.gwt.event.dom.client.ClickEvent;
|
|||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.dom.client.FocusEvent;
|
import com.google.gwt.event.dom.client.FocusEvent;
|
||||||
import com.google.gwt.event.dom.client.FocusHandler;
|
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;
|
||||||
import com.google.gwt.user.client.DOM;
|
import com.google.gwt.user.client.DOM;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.CheckBox;
|
import com.google.gwt.user.client.ui.CheckBox;
|
||||||
@@ -77,6 +80,14 @@ class ProjectWatchPanel extends Composite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
box.addKeyPressHandler(new KeyPressHandler() {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
doAddNew();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
fp.add(nameTxt);
|
fp.add(nameTxt);
|
||||||
|
|
||||||
addNew = new Button(Util.C.buttonWatchProject());
|
addNew = new Button(Util.C.buttonWatchProject());
|
||||||
|
|||||||
@@ -60,6 +60,14 @@ public class UsernamePanel extends Composite {
|
|||||||
userNameTxt.addStyleName(Gerrit.RESOURCES.css().sshPanelUsername());
|
userNameTxt.addStyleName(Gerrit.RESOURCES.css().sshPanelUsername());
|
||||||
userNameTxt.setVisibleLength(16);
|
userNameTxt.setVisibleLength(16);
|
||||||
userNameTxt.setReadOnly(!canEditUserName());
|
userNameTxt.setReadOnly(!canEditUserName());
|
||||||
|
userNameTxt.addKeyPressHandler(new KeyPressHandler() {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
doChangeUserName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
changeUserName = new Button(Util.C.buttonChangeUserName());
|
changeUserName = new Button(Util.C.buttonChangeUserName());
|
||||||
changeUserName.setVisible(canEditUserName());
|
changeUserName.setVisible(canEditUserName());
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ import com.google.gerrit.common.PageLinks;
|
|||||||
import com.google.gerrit.reviewdb.AccountGroup;
|
import com.google.gerrit.reviewdb.AccountGroup;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.event.dom.client.KeyCodes;
|
||||||
|
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||||
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
import com.google.gwt.user.client.History;
|
import com.google.gwt.user.client.History;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
@@ -64,6 +67,14 @@ public class GroupListScreen extends AccountScreen {
|
|||||||
|
|
||||||
addTxt = new NpTextBox();
|
addTxt = new NpTextBox();
|
||||||
addTxt.setVisibleLength(60);
|
addTxt.setVisibleLength(60);
|
||||||
|
addTxt.addKeyPressHandler(new KeyPressHandler() {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
doCreateGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
fp.add(addTxt);
|
fp.add(addTxt);
|
||||||
|
|
||||||
addNew = new Button(Util.C.buttonCreateGroup());
|
addNew = new Button(Util.C.buttonCreateGroup());
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ import com.google.gwt.event.dom.client.ClickEvent;
|
|||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.dom.client.FocusEvent;
|
import com.google.gwt.event.dom.client.FocusEvent;
|
||||||
import com.google.gwt.event.dom.client.FocusHandler;
|
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;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.DeferredCommand;
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.CheckBox;
|
import com.google.gwt.user.client.ui.CheckBox;
|
||||||
@@ -109,6 +114,14 @@ public class ProjectBranchesPanel extends Composite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
nameTxtBox.addKeyPressHandler(new KeyPressHandler() {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
doAddNewBranch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
addGrid.setText(0, 0, Util.C.columnBranchName() + ":");
|
addGrid.setText(0, 0, Util.C.columnBranchName() + ":");
|
||||||
addGrid.setWidget(0, 1, nameTxtBox);
|
addGrid.setWidget(0, 1, nameTxtBox);
|
||||||
|
|
||||||
@@ -134,6 +147,14 @@ public class ProjectBranchesPanel extends Composite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
irevTxtBox.addKeyPressHandler(new KeyPressHandler() {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
doAddNewBranch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
addGrid.setText(1, 0, Util.C.initialRevision() + ":");
|
addGrid.setText(1, 0, Util.C.initialRevision() + ":");
|
||||||
addGrid.setWidget(1, 1, irevTxtBox);
|
addGrid.setWidget(1, 1, irevTxtBox);
|
||||||
|
|
||||||
@@ -165,11 +186,20 @@ public class ProjectBranchesPanel extends Composite {
|
|||||||
private void doAddNewBranch() {
|
private void doAddNewBranch() {
|
||||||
String branchName = nameTxtBox.getText();
|
String branchName = nameTxtBox.getText();
|
||||||
if ("".equals(branchName) || Util.C.defaultBranchName().equals(branchName)) {
|
if ("".equals(branchName) || Util.C.defaultBranchName().equals(branchName)) {
|
||||||
|
nameTxtBox.setFocus(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String rev = irevTxtBox.getText();
|
String rev = irevTxtBox.getText();
|
||||||
if ("".equals(rev) || Util.C.defaultRevisionSpec().equals(rev)) {
|
if ("".equals(rev) || Util.C.defaultRevisionSpec().equals(rev)) {
|
||||||
|
irevTxtBox.setText("HEAD");
|
||||||
|
DeferredCommand.addCommand(new Command() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
irevTxtBox.selectAll();
|
||||||
|
irevTxtBox.setFocus(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ import com.google.gwt.event.dom.client.ClickEvent;
|
|||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.dom.client.FocusEvent;
|
import com.google.gwt.event.dom.client.FocusEvent;
|
||||||
import com.google.gwt.event.dom.client.FocusHandler;
|
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;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.CheckBox;
|
import com.google.gwt.user.client.ui.CheckBox;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
@@ -163,12 +166,28 @@ public class ProjectRightsPanel extends Composite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
nameTxtBox.addKeyPressHandler(new KeyPressHandler() {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
doAddNewRight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
addGrid.setText(1, 0, Util.C.columnGroupName() + ":");
|
addGrid.setText(1, 0, Util.C.columnGroupName() + ":");
|
||||||
addGrid.setWidget(1, 1, nameTxt);
|
addGrid.setWidget(1, 1, nameTxt);
|
||||||
|
|
||||||
referenceTxt = new NpTextBox();
|
referenceTxt = new NpTextBox();
|
||||||
referenceTxt.setVisibleLength(50);
|
referenceTxt.setVisibleLength(50);
|
||||||
referenceTxt.setText("");
|
referenceTxt.setText("");
|
||||||
|
referenceTxt.addKeyPressHandler(new KeyPressHandler() {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
doAddNewRight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
addGrid.setText(2, 0, Util.C.columnRefName() + ":");
|
addGrid.setText(2, 0, Util.C.columnRefName() + ":");
|
||||||
addGrid.setWidget(2, 1, referenceTxt);
|
addGrid.setWidget(2, 1, referenceTxt);
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ import com.google.gerrit.client.Gerrit;
|
|||||||
import com.google.gerrit.client.admin.Util;
|
import com.google.gerrit.client.admin.Util;
|
||||||
import com.google.gwt.event.dom.client.BlurEvent;
|
import com.google.gwt.event.dom.client.BlurEvent;
|
||||||
import com.google.gwt.event.dom.client.BlurHandler;
|
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.ClickHandler;
|
||||||
import com.google.gwt.event.dom.client.FocusEvent;
|
import com.google.gwt.event.dom.client.FocusEvent;
|
||||||
import com.google.gwt.event.dom.client.FocusHandler;
|
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;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
@@ -60,6 +64,14 @@ public class AddMemberBox extends Composite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
nameTxtBox.addKeyPressHandler(new KeyPressHandler() {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
addMember.fireEvent(new ClickEvent() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
addPanel.add(nameTxt);
|
addPanel.add(nameTxt);
|
||||||
addPanel.add(addMember);
|
addPanel.add(addMember);
|
||||||
|
|||||||
Reference in New Issue
Block a user