PDA

View Full Version : Closing Window widget when ESC key is pressed



Umashanthi
2 Aug 2010, 6:26 AM
Hi,

I have a Grid widget and I have added a listener to show a Window pop-up when clicked on it. In that pop-up window (first window) I have another Grid and which also shows a pop-up Window when clicked on a cell. I am using the Window widget for both the pop-ups.
I used the following line of code to enable the Window widget to close when the ESC key is pressed.
window.setOnEsc(true);

I set this property for both the Window widgets. But when I get the first window poped-up and when I press the ESC key, the widow doesn't get closed. After I click on the grid on the first window and get the second window pop-up, when I press the ESC key, the first window get closed, but not the second window.

Is the method I mentioned above the right method to enable window closing on ESC key?
If so, any clues why this happens the way I mentioned above?
If not could you please suggest me the right way of doing it?


Thanks in advance,
Umashanthi

sven
2 Aug 2010, 6:35 AM
Make sure that the window that you want to close with ESC has the focus. Only the window that has the focus will get closed if closeOnEsc is set to true.

Umashanthi
2 Aug 2010, 6:53 AM
Sorry, I couldn't get you completely. What do you mean by "the window having the focus"?
Even when I clicked somewhere on the second window and press the ESC key, only the first window get closed.

sven
2 Aug 2010, 7:01 AM
It looks like the target of your esc key is the wrong window element. The target is that element, that currently has focus. I tried to reproduce this with GXT 2.2 beta1 and could not reproduce this.

Which version of GXT are you using? Have you tried to reproduce this in a small standalone testcase implementing EntryPoint?

Umashanthi
2 Aug 2010, 8:06 AM
I am using GXT 2.1.1. I tried with a standalone app and it works for the window with focus ( I had buttons and focused on them).

But in my original app, there is no way to focus on the second window since it has only text in labels.
Is there any other way to enable closing the window when ESC key is pressed?

Umashanthi
2 Aug 2010, 8:40 AM
I just tried with GXT 2.2 Beta and it works fine :) No focusing problems as well.

Thanks a lot Sven...