Browse Source

fixes #1412

svn changeset:4345/svn branch:trunk
tags/6.7.0.beta1
Matti Tahvonen 16 years ago
parent
commit
9e8bfbb5b4

+ 2
- 4
src/com/itmill/toolkit/demo/KeyboardShortcut.java View File

@@ -35,9 +35,8 @@ public class KeyboardShortcut extends Application implements Handler {
+ "applications. (see our article on <a href=\"http://www.itmill"
+ ".com/articles/Keybindings_in_Web_Browsers.htm\">"
+ "www.itmill.com)</a></p>"
+ "Events are attached to Window in this application, so a "
+ "component inside window must be focused to fire event on"
+ " keyboard shortcut.</p>"
+ "<p>Focus must be inside web application (eg. not in address "
+ "bar) for shortcuts to work. By default app element is focused.</p>"
+ "<strong>Shortcuts used in this example:</strong> "
+ "<br/>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) {

+ 18
- 0
src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java View File

@@ -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;
}

Loading…
Cancel
Save