From: Matti Tahvonen Date: Tue, 6 May 2008 11:47:49 +0000 (+0000) Subject: fixes #1412 X-Git-Tag: 6.7.0.beta1~4822 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9e8bfbb5b47ae5d9522aa6dd1dd7e9a63c48839c;p=vaadin-framework.git fixes #1412 svn changeset:4345/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/demo/KeyboardShortcut.java b/src/com/itmill/toolkit/demo/KeyboardShortcut.java index 3dd157ea8c..0c13f4d6c3 100644 --- a/src/com/itmill/toolkit/demo/KeyboardShortcut.java +++ b/src/com/itmill/toolkit/demo/KeyboardShortcut.java @@ -35,9 +35,8 @@ public class KeyboardShortcut extends Application implements Handler { + "applications. (see our article on " + "www.itmill.com)

" - + "Events are attached to Window in this application, so a " - + "component inside window must be focused to fire event on" - + " keyboard shortcut.

" + + "

Focus must be inside web application (eg. not in address " + + "bar) for shortcuts to work. By default app element is focused.

" + "Shortcuts used in this example: " + "
ESC restarts program, ctrl-shift-a (Button A), " + "ctrl-shift-z (Button Z), ctrl-shift-x (Button X)", @@ -104,7 +103,6 @@ public class KeyboardShortcut extends Application implements Handler { w.addActionHandler(this); - f.focus(); } public Action[] getActions(Object target, Object sender) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java index fe849a6bb2..128c9160cf 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.Iterator; import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; @@ -55,13 +56,30 @@ public class IView extends SimplePanel implements Paintable, public IView(String elementId) { super(); setStyleName(CLASSNAME); + DOM.sinkEvents(getElement(), Event.ONKEYDOWN); + DOM.setElementPropertyInt(getElement(), "tabIndex", 0); + RootPanel.get(elementId).add(this); Window.addWindowResizeListener(this); + + // set focus to iview element by default to listen possible keyboard + // shortcuts + focus(getElement()); + } + private static native void focus(Element el) + /*-{ + try { + el.focus(); + } catch (e) { + + } + }-*/; + public String getTheme() { return theme; }