Doubt about ShortcutListener

I need to put a shortcutlistener in 2 fields so I try:

txtBuscaReal.addShortcutListener(new ShortcutListener("Shortcut Name", ShortcutAction.KeyCode.ENTER, null) {
	@Override
	public void handleAction(Object sender, Object target) {
		System.out.println("foi 1");
	}
});

txtBusca.addShortcutListener(new ShortcutListener("Shortcut Name", ShortcutAction.KeyCode.ENTER, null) {
	@Override
	public void handleAction(Object sender, Object target) {
		System.out.println("foi 2");
	}
});

but only works the first enter (in my txtBuscaReal textfield) why? tks

Hi Fabio,
if I correctly remember on the client side only the first matching shortcut action is fired.

You can however define a single listener at UI level (as addShortcutListener is just a shortcut for getActionManager().addAction(shortcut)).

For example

TextField t1 = new TextField("T1");
TextField t2 = new TextField("T2");

ShortcutListener action = new ShortcutListener("Action", ShortcutAction.KeyCode.ENTER, null) {
	@Override
	public void handleAction(Object sender, Object target) {
		if (target == t1) {
			System.out.println("ACTION from textfield T1");
		} else if (target == t2) {
			System.out.println("ACTION from textfield T2");
		}
	}
};
getActionManager().addAction(action);

HTH
Marco

Or, if you need more fine-tuned control of key actions, try the [KeyActions]
(https://vaadin.com/directory/component/keyactions) add-on.