blob: c617b072487a02f49398f126fcd9f30afb54f5c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package com.vaadin.tests.tickets;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.ShortcutAction;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.ui.TextField;
public class Ticket1365 extends com.vaadin.Application.LegacyApplication
implements Handler {
TextField f = new TextField();
Label status = new Label("ENTER and CTRL-S fires shortcut action.");
@Override
public void init() {
final LegacyWindow main = new LegacyWindow(getClass().getName()
.substring(getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
main.addComponent(f);
main.addComponent(status);
main.addActionHandler(this);
f.focus();
}
final static private Action[] actions = new Action[] {
new ShortcutAction("Enter", ShortcutAction.KeyCode.ENTER,
new int[] {}),
new ShortcutAction("CTRL-S", ShortcutAction.KeyCode.S,
new int[] { ShortcutAction.ModifierKey.CTRL }), };
@Override
public Action[] getActions(Object target, Object sender) {
return actions;
}
@Override
public void handleAction(Action action, Object sender, Object target) {
status.setValue("Pressed " + action.getCaption()
+ " to fire shortcut. Texfield value: " + f.getValue());
f.focus();
}
}
|