Hi,
I’ve been trying to make a TextField that catches an enter-press. I’m developing it for login now, but might use it elsewhere. However, I’m having trouble. I can catch the presses fine with my code, but the “secret” variable doesn’t work with my code, everything is echoed back normally. Is there an easier alternative or can you point out what’s wrong with my code?
public class VEnterCatchingTextField extends VTextField {
@SuppressWarnings("deprecation")
public VEnterCatchingTextField() {
addKeyboardListener(new KeyboardListenerAdapter() {
@Override
public void onKeyPress(Widget sender, char keyCode, int modifiers) {
if (keyCode == KeyboardListener.KEY_ENTER) enterPressed();
}
});
}
public void enterPressed() {
client.updateVariable(id, "enterPressed", true, true);
}
}
public class EnterCatchingTextField extends TextField {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public void changeVariables(Object source, Map variables) {
super.changeVariables(source, variables);
if (variables.containsKey("enterPressed")) {
// do stuff here
}
}
@Override
public String getTag() {
return ("entercatchingtextfield");
}
}