I use GWT-Ext library for building GUI for a webapp. I'd like to process an ENTER key press inside of the NumberField.
It should be like this:
final NumberField requiredHeight = new NumberField();
requiredHeight.setValue(125);
requiredHeight.setAllowBlank(false);
requiredHeight.setAllowNegative(false);
requiredHeight.setAllowDecimals(false);
KeyListener listener = new KeyListener() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()==13)
addPortlet(requiredHeight.getValue().intValue());
}
};
requiredHeight.addKeyListener(listener);
But the code doesn't do anything! What am I doing wrong? Generally speaking, what is the best way to add such a handler to the field?