Allow "Keyboard Shortcuts" help popup to be closed with Escape key
Bug: Issue 1996
Change-Id: I7391acad508657b3c7d3e3211bb7a51778f4a7e9
diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/globalkey/client/KeyHelpPopup.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/globalkey/client/KeyHelpPopup.java
index 7bd0233..6f8bf80 100644
--- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/globalkey/client/KeyHelpPopup.java
+++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/globalkey/client/KeyHelpPopup.java
@@ -16,8 +16,11 @@
import com.google.gwt.event.dom.client.ClickEvent;
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.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.FlowPanel;
@@ -38,7 +41,7 @@
public class KeyHelpPopup extends PluginSafePopupPanel implements
- KeyPressHandler {
+ KeyPressHandler, KeyUpHandler {
private final FocusPanel focus;
public KeyHelpPopup() {
@@ -77,6 +80,7 @@
DOM.setStyleAttribute(focus.getElement(), "outline", "0px");
DOM.setElementAttribute(focus.getElement(), "hideFocus", "true");
focus.addKeyPressHandler(this);
+ focus.addKeyUpHandler(this);
add(focus);
}
@@ -100,6 +104,13 @@
hide();
}
+ @Override
+ public void onKeyUp(final KeyUpEvent event) {
+ if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
+ hide();
+ }
+ }
+
private void populate(final Grid lists) {
int end[] = new int[5];
int column = 0;