]> source.dussan.org Git - vaadin-framework.git/commitdiff
added constants for num keys
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 11 Apr 2007 12:21:24 +0000 (12:21 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 11 Apr 2007 12:21:24 +0000 (12:21 +0000)
svn changeset:1195/svn branch:trunk

src/com/itmill/toolkit/demo/KeyboardShortcut.java

index 4584ec6597efaa6a35ee4d74cd24971f72ca67fb..acb0c6573849e94bec060e791081d7e10f5a3966 100644 (file)
@@ -18,6 +18,8 @@ public class KeyboardShortcut extends com.itmill.toolkit.Application implements
 
        Button d;
 
+       Button e;
+
        private AbstractField f;
 
        public void init() {
@@ -70,6 +72,9 @@ public class KeyboardShortcut extends com.itmill.toolkit.Application implements
                main.addComponent(d);
                d = new Button("Click to focus Textfield", this, "setFocusF");
                main.addComponent(d);
+               e = new Button("Test buton", this, "buttonEHandler");
+               e.addActionHandler(this);
+               main.addComponent(e);
                f.focus();
        }
 
@@ -93,6 +98,18 @@ public class KeyboardShortcut extends com.itmill.toolkit.Application implements
                                        ShortcutAction.KeyCode.C, new int[] {
                                                        ShortcutAction.ModifierKey.CTRL,
                                                        ShortcutAction.ModifierKey.SHIFT });
+               } else if (sender == e) {
+                       actions = new Action[5];
+                       actions[0] = (Action) new ShortcutAction("Button E action A",
+                                       ShortcutAction.KeyCode.A, null);
+                       actions[1] = (Action) new ShortcutAction("Button E action B",
+                                       ShortcutAction.KeyCode.B, null);
+                       actions[2] = (Action) new ShortcutAction("Button E action F1",
+                                       ShortcutAction.KeyCode.F1, null);
+                       actions[3] = (Action) new ShortcutAction("Button E action F2",
+                                       ShortcutAction.KeyCode.F2, null);
+                       actions[4] = (Action) new ShortcutAction("Button E action F3",
+                                       ShortcutAction.KeyCode.F3, null);
                } else if (sender == a) {
                        actions[0] = (Action) new ShortcutAction("Button a action",
                                        ShortcutAction.KeyCode.A,
@@ -112,6 +129,8 @@ public class KeyboardShortcut extends com.itmill.toolkit.Application implements
                        this.buttonBHandler();
                if (target == c)
                        this.buttonCHandler();
+               if (target == e)
+                       this.buttonEHandler();
                if (target == close)
                        this.close();
        }
@@ -127,4 +146,7 @@ public class KeyboardShortcut extends com.itmill.toolkit.Application implements
        public void buttonCHandler() {
                main.addComponent(new Label("Button C handler fired"));
        }
+       public void buttonEHandler() {
+               main.addComponent(new Label("Button E handler fired"));
+       }
 }