Closing a GWT DialogBox on 'Esc' keypress
Posted by zone817To 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); }
0 comments:
Post a Comment