summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-07-27 14:39:23 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-07-27 14:39:23 +0000
commitfbddc9eff67a8392246d333d0c826d4e71edafa8 (patch)
tree9acb066cdc4e7d67d4130a402b1f124d46daef9b /src
parent8374a0aa32dec95d8fb72f6f0d3cf286cc3684f4 (diff)
downloadvaadin-framework-fbddc9eff67a8392246d333d0c826d4e71edafa8.tar.gz
vaadin-framework-fbddc9eff67a8392246d333d0c826d4e71edafa8.zip
Explicitly delegate keyboard events from the PopupView popup to the relevant shortcut action handler (#8193)
svn changeset:24031/svn branch:6.8
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VPopupView.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java
index 907e11ac2d..06a9c738a1 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java
@@ -11,6 +11,8 @@ import java.util.Set;
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.KeyDownEvent;
+import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.DOM;
@@ -33,6 +35,7 @@ import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VCaption;
import com.vaadin.terminal.gwt.client.VCaptionWrapper;
import com.vaadin.terminal.gwt.client.VTooltip;
+import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea;
public class VPopupView extends HTML implements Container, Iterable<Widget> {
@@ -239,8 +242,22 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
private final Set<Element> activeChildren = new HashSet<Element>();
private boolean hiding = false;
+ private ShortcutActionHandler shortcutActionHandler;
+
public CustomPopup() {
super(true, false, true); // autoHide, not modal, dropshadow
+
+ // Delegate popup keyboard events to the relevant handler. The
+ // events do not propagate automatically because the popup is
+ // directly attached to the RootPanel.
+ addDomHandler(new KeyDownHandler() {
+ public void onKeyDown(KeyDownEvent event) {
+ if (shortcutActionHandler != null) {
+ shortcutActionHandler.handleKeyboardEvent(Event
+ .as(event.getNativeEvent()));
+ }
+ }
+ }, KeyDownEvent.getType());
}
// For some reason ONMOUSEOUT events are not always received, so we have
@@ -290,12 +307,26 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
remove(popupComponentWidget);
}
hasHadMouseOver = false;
+ shortcutActionHandler = null;
super.hide(autoClosed);
}
@Override
public void show() {
hiding = false;
+
+ // Find the shortcut action handler that should handle keyboard
+ // events from the popup. The events do not propagate automatically
+ // because the popup is directly attached to the RootPanel.
+ Widget widget = VPopupView.this;
+ while (shortcutActionHandler == null && widget != null) {
+ if (widget instanceof ShortcutActionHandlerOwner) {
+ shortcutActionHandler = ((ShortcutActionHandlerOwner) widget)
+ .getShortcutActionHandler();
+ }
+ widget = widget.getParent();
+ }
+
super.show();
}