PDA

View Full Version : textfield losing focus



pieterbreed
23 Mar 2009, 11:56 AM
Hi,

I am using GXT and I have a TextField<String> that listens for keypresses which then causes filtering to be done on a grid. The keypresses handler looks like this:

shortcutTxtField.addKeyListener(new KeyListener() {
public void componentKeyUp(final ComponentEvent pEvent) {
super.componentKeyUp(pEvent);

// raise the filter with the correct filter specification
// but make sure that the text field retains the focus
String value = shortcutTxtField.getValue();
raiseSetShortcutFilterSpecificationEvent(value);

shortcutTxtField.focus();
}
}
});

the raiseSetShortcutFilterSPecificationEvent() method causes a List<> to be created which is then rebound to the DataStore of a Grid<> on the page, causing the items to be filtered with each keypress.

However, as soon as the liststore is modified and the grid updates, the textfield loses focus and I can't set it back with the .focus() method as above. Does anyone have any idea why this happens?

Regards,
Pieter