Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
ShortcutListener on Multiple TextFields question
I'm kind of new to all this.
I have 2 TextFields.
public TextField t1 = new TextField();
public TextField t2 = new TextField();
I have 1 shortcutListener
ShortcutListener enter = new ShortcutListener("enter",
KeyCode.ENTER, null) {
@Override
public void handleAction(Object sender, Object target) {
///HOW DO I CHECK WITCH TextField CALLED IT
///something like
if(t1){
DO SOMETHING
}else{
DO SOMETHING ELSE
}
}
};
t1.addShortcutListener(enter);
t2.addShortcutListener(enter);
I can't figure out from what Object (sender,target) I have to take what info.
If you put a breakpoint inside the handleAction method you can see that the Object target is in this case in fact of type TextField, while the Object sender is your UI. So just if (t1.equals(target)) {...} should do the trick.