Вы можете переопределить метод onPreviewNativeEvent()
класса DialogBox
:
public void onModuleLoad() {
ExtendedDialogBox dialog = new ExtendedDialogBox();
dialog.add(new Label("some content"));
dialog.show();
}
private class ExtendedDialogBox extends DialogBox {
@Override
protected void onPreviewNativeEvent(NativePreviewEvent event) {
super.onPreviewNativeEvent(event);
switch (event.getTypeInt()) {
case Event.ONKEYDOWN:
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) {
hide();
}
break;
}
}
}