Set focus on Continue Button in ErrorDialog
Initially set the keyboard focus on the Continue Button when the ErrorDialog is shown. This allows the user to handle this dialog without using the mouse. Signed-off-by: Edwin Kempin <edwin.kempin@gmail.com>
This commit is contained in:
@@ -17,6 +17,8 @@ package com.google.gerrit.client;
|
||||
import com.google.gerrit.client.rpc.RpcConstants;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.StatusCodeException;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
@@ -30,6 +32,7 @@ import com.google.gwtjsonrpc.client.RemoteJsonException;
|
||||
public class ErrorDialog extends PluginSafePopupPanel {
|
||||
private final Label text;
|
||||
private final FlowPanel body;
|
||||
private final Button closey;
|
||||
|
||||
protected ErrorDialog() {
|
||||
super(/* auto hide */false, /* modal */true);
|
||||
@@ -44,7 +47,7 @@ public class ErrorDialog extends PluginSafePopupPanel {
|
||||
final FlowPanel buttons = new FlowPanel();
|
||||
buttons.setStyleName(Gerrit.RESOURCES.css().errorDialogButtons());
|
||||
|
||||
final Button closey = new Button();
|
||||
closey = new Button();
|
||||
closey.setText(Gerrit.C.errorDialogContinue());
|
||||
closey.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
@@ -52,6 +55,16 @@ public class ErrorDialog extends PluginSafePopupPanel {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
closey.addKeyPressHandler(new KeyPressHandler() {
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
// if the close button is triggered by a key we need to consume the key
|
||||
// event, otherwise the key event would be propagated to the parent
|
||||
// screen and eventually trigger some unwanted action there after the
|
||||
// error dialog was closed
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
buttons.add(closey);
|
||||
|
||||
final FlowPanel center = new FlowPanel();
|
||||
@@ -118,5 +131,6 @@ public class ErrorDialog extends PluginSafePopupPanel {
|
||||
@Override
|
||||
public void center() {
|
||||
show();
|
||||
closey.setFocus(true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user