summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-05-21 11:52:12 -0700
committerShawn O. Pearce <sop@google.com>2009-05-21 11:52:12 -0700
commitc52117cc59906aa3bb5a9aa4a669900f5d712b9a (patch)
tree06c5fdfb1017a8da4efc13617ea9a2115299839e
parentc80a47113d887406d9733521a50cf9d5e2c817be (diff)
downloadgwtexpui-c52117cc59906aa3bb5a9aa4a669900f5d712b9a.tar.gz
Make '?' toggle the help dialog closed
Bug: GERRIT-184 Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--src/main/java/com/google/gwtexpui/globalkey/client/ShowHelpCommand.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/ShowHelpCommand.java b/src/main/java/com/google/gwtexpui/globalkey/client/ShowHelpCommand.java
index 0620244..f95c55e 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/ShowHelpCommand.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/ShowHelpCommand.java
@@ -15,12 +15,16 @@
package com.google.gwtexpui.globalkey.client;
import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.logical.shared.CloseEvent;
+import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
public class ShowHelpCommand extends KeyCommand {
public static final ShowHelpCommand INSTANCE = new ShowHelpCommand();
+ private static KeyHelpPopup current;
public ShowHelpCommand() {
super(0, '?', Util.C.showHelp());
@@ -28,7 +32,21 @@ public class ShowHelpCommand extends KeyCommand {
@Override
public void onKeyPress(final KeyPressEvent event) {
+ if (current != null) {
+ // Already open? Close the dialog.
+ //
+ current.hide();
+ current = null;
+ return;
+ }
+
final KeyHelpPopup help = new KeyHelpPopup();
+ help.addCloseHandler(new CloseHandler<PopupPanel>() {
+ @Override
+ public void onClose(final CloseEvent<PopupPanel> event) {
+ current = null;
+ }
+ });
help.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(final int pWidth, final int pHeight) {