PDA

View Full Version : Capture Key Board Enter Key to GXT Dialog



ramnathlikesu
8 Sep 2011, 10:05 AM
Hi,

I have requirement to capture the Enter key of Keyboard and fire the GXT Dialog OK Button.

Below is the code i have written.
Dialog
private class SubmitListener extends KeyboardListenerAdapter {
public void onKeyPress(Widget sender, char key, int mods) {
if (KeyboardListener.KEY_ENTER == key)
button.click();
}

Every time i need to add this Listener to the GXT Dialog. In my application, GXT Dialog is used lot of times. I need this functionality to be applied for total application.

I didn't got any idea how to apply this functionality to all Dialogue in my application.
Request you to please help me in this.

Thank you...
Regards,
Ramnath R



}

Alejandro.Casagrande
8 Sep 2011, 10:28 AM
May be you can extend the Dialog class and add a custom method to capture Enter Key, something like this:




KeyListener keyListener = new KeyListener() {
public void componentKeyUp(ComponentEvent event) {
if (event.getKeyCode()==13) {
(button.click or the method called in the button click event)
}
}
};



Regards

ramnathlikesu
19 Sep 2011, 8:08 AM
Hi,

Thanks for your reply.
If i go for your solution, I need to change lot of code in our application.

Is it any possibility to a add listener to mainPanel of the application and whenever user enters the keyBoard enter key, gets the active dialog...

Please suggest me.
Thank you...

Regards,
Ramnath R