diff options
author | Artur Signell <artur@vaadin.com> | 2016-01-01 11:53:42 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-01-05 14:06:42 +0200 |
commit | 29a368d0f7efe24237b36e716e1c59418073163f (patch) | |
tree | 63260558f00854b44788869fca089feeb4cd1e65 /client | |
parent | 691fcd02c0dab910caaccff1af57da6613be9009 (diff) | |
download | vaadin-framework-29a368d0f7efe24237b36e716e1c59418073163f.tar.gz vaadin-framework-29a368d0f7efe24237b36e716e1c59418073163f.zip |
Listen to body for shortcut actions for standalone apps (#19392)
Change-Id: I2e9d5e95c7b0ba3907c9772aee9fbfadb6baabde
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VUI.java | 12 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/ui/UIConnector.java | 21 |
2 files changed, 19 insertions, 14 deletions
diff --git a/client/src/com/vaadin/client/ui/VUI.java b/client/src/com/vaadin/client/ui/VUI.java index 963d83a6e6..08641ad6ba 100644 --- a/client/src/com/vaadin/client/ui/VUI.java +++ b/client/src/com/vaadin/client/ui/VUI.java @@ -30,8 +30,6 @@ import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.http.client.URL; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Event; import com.google.gwt.user.client.History; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; @@ -349,16 +347,6 @@ public class VUI extends SimplePanel implements ResizeHandler, return isEmbedded(); } - @Override - public void onBrowserEvent(Event event) { - super.onBrowserEvent(event); - int type = DOM.eventGetType(event); - if (type == Event.ONKEYDOWN && actionHandler != null) { - actionHandler.handleKeyboardEvent(event); - return; - } - } - /* * (non-Javadoc) * diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index f5656dfdc4..9ffb9cfba9 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -32,6 +32,8 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.StyleElement; import com.google.gwt.dom.client.StyleInjector; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; import com.google.gwt.event.logical.shared.ResizeEvent; @@ -495,8 +497,23 @@ public class UIConnector extends AbstractSingleComponentContainerConnector getHead().appendChild(style); } - DOM.sinkEvents(getWidget().getElement(), Event.ONKEYDOWN - | Event.ONSCROLL); + Widget shortcutContextWidget = getWidget(); + if (applicationConnection.getConfiguration().isStandalone()) { + // Listen to body for standalone apps (#19392) + shortcutContextWidget = RootPanel.get(); // document body + } + + shortcutContextWidget.addDomHandler(new KeyDownHandler() { + @Override + public void onKeyDown(KeyDownEvent event) { + if (getWidget().actionHandler != null) { + getWidget().actionHandler.handleKeyboardEvent((Event) event + .getNativeEvent().cast()); + } + } + }, KeyDownEvent.getType()); + + DOM.sinkEvents(getWidget().getElement(), Event.ONSCROLL); RootPanel root = RootPanel.get(rootPanelId); |