Allow "Keyboard Shortcuts" help popup to be closed with Escape key

Bug: Issue 1996
Change-Id: I7391acad508657b3c7d3e3211bb7a51778f4a7e9
This commit is contained in:
David Pursehouse
2013-07-08 11:17:35 +09:00
parent b7886b9c65
commit 052cbef14f

View File

@@ -16,8 +16,11 @@ package com.google.gwtexpui.globalkey.client;
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.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler; 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.DOM;
import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
@@ -38,7 +41,7 @@ import java.util.List;
public class KeyHelpPopup extends PluginSafePopupPanel implements public class KeyHelpPopup extends PluginSafePopupPanel implements
KeyPressHandler { KeyPressHandler, KeyUpHandler {
private final FocusPanel focus; private final FocusPanel focus;
public KeyHelpPopup() { public KeyHelpPopup() {
@@ -77,6 +80,7 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
DOM.setStyleAttribute(focus.getElement(), "outline", "0px"); DOM.setStyleAttribute(focus.getElement(), "outline", "0px");
DOM.setElementAttribute(focus.getElement(), "hideFocus", "true"); DOM.setElementAttribute(focus.getElement(), "hideFocus", "true");
focus.addKeyPressHandler(this); focus.addKeyPressHandler(this);
focus.addKeyUpHandler(this);
add(focus); add(focus);
} }
@@ -100,6 +104,13 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
hide(); hide();
} }
@Override
public void onKeyUp(final KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
hide();
}
}
private void populate(final Grid lists) { private void populate(final Grid lists) {
int end[] = new int[5]; int end[] = new int[5];
int column = 0; int column = 0;