SideBySide2: Restore focus to CM B after showing key binding help

This way ?, ? then / works as expected, the user can open the
help close it again and immediately use a binding in the right
side CM3 instance.

Change-Id: Ia3eede648ca2c79bda028f32e78c4295a61d3e33
This commit is contained in:
Shawn Pearce
2014-01-17 16:13:51 -08:00
parent e4c3d5a6d9
commit 3b540bb7c0
2 changed files with 20 additions and 2 deletions

View File

@@ -14,18 +14,27 @@
package com.google.gwtexpui.globalkey.client;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
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.event.shared.EventBus;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.SimpleEventBus;
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 final EventBus BUS = new SimpleEventBus();
private static KeyHelpPopup current;
public static HandlerRegistration addFocusHandler(FocusHandler fh) {
return BUS.addHandler(FocusEvent.getType(), fh);
}
public ShowHelpCommand() {
super(0, '?', KeyConstants.I.showHelp());
}
@@ -36,7 +45,6 @@ public class ShowHelpCommand extends KeyCommand {
// Already open? Close the dialog.
//
current.hide();
current = null;
return;
}
@@ -45,6 +53,7 @@ public class ShowHelpCommand extends KeyCommand {
@Override
public void onClose(final CloseEvent<PopupPanel> event) {
current = null;
BUS.fireEvent(new FocusEvent() {});
}
});
current = help;

View File

@@ -44,6 +44,8 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.FocusEvent;
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.logical.shared.ResizeEvent;
@@ -458,12 +460,19 @@ public class SideBySide2 extends Screen {
} else {
keysComment = null;
}
removeKeyHandlerRegistrations();
handlers.add(GlobalKey.add(this, keysNavigation));
if (keysComment != null) {
handlers.add(GlobalKey.add(this, keysComment));
}
handlers.add(GlobalKey.add(this, keysAction));
handlers.add(ShowHelpCommand.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
cmB.focus();
}
}));
}
private void display(final CommentsCollections comments) {