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:
@@ -14,18 +14,27 @@
|
|||||||
|
|
||||||
package com.google.gwtexpui.globalkey.client;
|
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.dom.client.KeyPressEvent;
|
||||||
import com.google.gwt.event.logical.shared.CloseEvent;
|
import com.google.gwt.event.logical.shared.CloseEvent;
|
||||||
import com.google.gwt.event.logical.shared.CloseHandler;
|
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.Window;
|
||||||
import com.google.gwt.user.client.ui.PopupPanel;
|
import com.google.gwt.user.client.ui.PopupPanel;
|
||||||
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
|
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
|
||||||
|
|
||||||
|
|
||||||
public class ShowHelpCommand extends KeyCommand {
|
public class ShowHelpCommand extends KeyCommand {
|
||||||
public static final ShowHelpCommand INSTANCE = new ShowHelpCommand();
|
public static final ShowHelpCommand INSTANCE = new ShowHelpCommand();
|
||||||
|
private static final EventBus BUS = new SimpleEventBus();
|
||||||
private static KeyHelpPopup current;
|
private static KeyHelpPopup current;
|
||||||
|
|
||||||
|
public static HandlerRegistration addFocusHandler(FocusHandler fh) {
|
||||||
|
return BUS.addHandler(FocusEvent.getType(), fh);
|
||||||
|
}
|
||||||
|
|
||||||
public ShowHelpCommand() {
|
public ShowHelpCommand() {
|
||||||
super(0, '?', KeyConstants.I.showHelp());
|
super(0, '?', KeyConstants.I.showHelp());
|
||||||
}
|
}
|
||||||
@@ -36,7 +45,6 @@ public class ShowHelpCommand extends KeyCommand {
|
|||||||
// Already open? Close the dialog.
|
// Already open? Close the dialog.
|
||||||
//
|
//
|
||||||
current.hide();
|
current.hide();
|
||||||
current = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +53,7 @@ public class ShowHelpCommand extends KeyCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void onClose(final CloseEvent<PopupPanel> event) {
|
public void onClose(final CloseEvent<PopupPanel> event) {
|
||||||
current = null;
|
current = null;
|
||||||
|
BUS.fireEvent(new FocusEvent() {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
current = help;
|
current = help;
|
||||||
|
@@ -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.Element;
|
||||||
import com.google.gwt.dom.client.NativeEvent;
|
import com.google.gwt.dom.client.NativeEvent;
|
||||||
import com.google.gwt.dom.client.Style.Unit;
|
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.KeyCodes;
|
||||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||||
import com.google.gwt.event.logical.shared.ResizeEvent;
|
import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||||
@@ -458,12 +460,19 @@ public class SideBySide2 extends Screen {
|
|||||||
} else {
|
} else {
|
||||||
keysComment = null;
|
keysComment = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeKeyHandlerRegistrations();
|
removeKeyHandlerRegistrations();
|
||||||
handlers.add(GlobalKey.add(this, keysNavigation));
|
handlers.add(GlobalKey.add(this, keysNavigation));
|
||||||
if (keysComment != null) {
|
if (keysComment != null) {
|
||||||
handlers.add(GlobalKey.add(this, keysComment));
|
handlers.add(GlobalKey.add(this, keysComment));
|
||||||
}
|
}
|
||||||
handlers.add(GlobalKey.add(this, keysAction));
|
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) {
|
private void display(final CommentsCollections comments) {
|
||||||
|
Reference in New Issue
Block a user