Reputation: 55
I am using GXT window to create a popup edit window for editing a form field. As I edit the text field, the form field also changes. But I want to capture when the user has clicked outside of the window. That is, I want to capture blur event on a window, is that possible?
Here is a sample of my code for the window:
final Window window = new Window();
window.setSize(450, 100);
window.setPlain(true);
window.setModal(true);
window.setBlinkModal(true);
window.setHeading("Edit Text");
window.setLayout(new FitLayout());
window.setIconStyle("icon-edit");
window.addWindowListener(new WindowListener() {
public void windowHide(WindowEvent wevent) {
//do something
}
});
Can anyone help? Thanks
Upvotes: 0
Views: 822
Reputation: 3639
This will work for GXT3. GXT2 seems to have the same window.addDomHandler api though so may work in that version as well.
I threw in the MouseOutHandler version too just in case you decide the user shouldn't have to click... Anyway choose your favorite!
window.addDomHandler(new BlurHandler() {
@Override public void onBlur(BlurEvent event) {
// TODO Auto-generated method stub
}
}, BlurEvent.getType());
window.addDomHandler(new MouseOutHandler() {
@Override public void onMouseOut(MouseOutEvent event) {
// TODO Auto-generated method stub
}
}, MouseOutEvent.getType());
By the way, when adding a DomHandler you don't need to sink the event.
Upvotes: 1