Closing a GWT DialogBox on 'Esc' keypress

0

To have a DialogBox do something on a keyboard event , its onPreviewNativeEvent should be overridden . A DialogBox can be made to hide itself on the 'Esc' key event by overriding it's OnPreviewNativeEvent method as follows

@Override protected void onPreviewNativeEvent(NativePreviewEvent event) { if (!event.isCanceled() && event.getTypeInt() == Event.ONKEYDOWN && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { this.hide(); } super.onPreviewNativeEvent(event); }

Read more »

0 comments:

Post a Comment

© Zone817. Powered by Blogger.