summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-06-26 15:02:39 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-06-26 15:02:39 +0000
commitd4d61d68982b5ce5ff435ab7c8644709cdc5950e (patch)
tree730808d1ce4dd9460e4c4c13d4b42eeeec996f4f /src
parent556730ab5ae0daefbbc2e077463c68d2081eaec3 (diff)
downloadvaadin-framework-d4d61d68982b5ce5ff435ab7c8644709cdc5950e.tar.gz
vaadin-framework-d4d61d68982b5ce5ff435ab7c8644709cdc5950e.zip
#8193 Listen to RootPanel keydown events to handle shortcut actions from PopupPanel/VOverlay widgets
svn changeset:23977/svn branch:6.8
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VView.java27
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java3
2 files changed, 25 insertions, 5 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java
index 6fdacc9607..3f0347c306 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VView.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java
@@ -18,6 +18,8 @@ import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.event.dom.client.DomEvent.Type;
+import com.google.gwt.event.dom.client.KeyDownEvent;
+import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.shared.EventHandler;
@@ -136,12 +138,31 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
// should not be in the document focus flow
getElement().setTabIndex(-1);
TouchScrollDelegate.enableTouchScrolling(this, getElement());
+
+ // Handle shortcut actions originated from the main window. Subwindow
+ // shortcut actions are handled by the subwindows themselves.
+ RootPanel.get().addDomHandler(new KeyDownHandler() {
+ public void onKeyDown(KeyDownEvent event) {
+
+ Event nativeEvent = event.getNativeEvent().cast();
+ com.google.gwt.user.client.Element target = nativeEvent
+ .getEventTarget().cast();
+ // Ensure the event originates from our application even in case
+ // we're embedded.
+ if (actionHandler != null
+ && (!isEmbedded() || (Util.getPaintableForElement(
+ connection, getParent(), target) != null))) {
+ actionHandler.handleKeyboardEvent(nativeEvent);
+ }
+ }
+ }, KeyDownEvent.getType());
}
/**
* Start to periodically monitor for parent element resizes if embedded
* application (e.g. portlet).
*/
+ @Override
protected void onLoad() {
super.onLoad();
if (isMonitoringParentSize()) {
@@ -569,10 +590,7 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
int type = DOM.eventGetType(event);
- if (type == Event.ONKEYDOWN && actionHandler != null) {
- actionHandler.handleKeyboardEvent(event);
- return;
- } else if (scrollable && type == Event.ONSCROLL) {
+ if (scrollable && type == Event.ONSCROLL) {
updateScrollPosition();
}
}
@@ -934,5 +952,4 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
public void focus() {
getElement().focus();
}
-
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index 2384ee7ddd..9b124ae466 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -1377,6 +1377,9 @@ public class VWindow extends VOverlay implements Container,
if (shortcutHandler != null) {
shortcutHandler
.handleKeyboardEvent(Event.as(event.getNativeEvent()));
+ // Don't let the event propagate to the RootPanel where VView
+ // listens to shortcut events of the main window.
+ event.stopPropagation();
return;
}
}