Example #1
0
  @Override
  public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
    if (allActiveDialogs_.get(allActiveDialogs_.size() - 1) != this) return;

    if (event.getTypeInt() == Event.ONKEYDOWN) {
      NativeEvent nativeEvent = event.getNativeEvent();
      switch (nativeEvent.getKeyCode()) {
        case KeyCodes.KEY_ENTER:
          ThemedButton defaultButton =
              defaultOverrideButton_ == null ? okButton_ : defaultOverrideButton_;
          if ((defaultButton != null) && defaultButton.isEnabled()) {
            nativeEvent.preventDefault();
            nativeEvent.stopPropagation();
            event.cancel();
            defaultButton.click();
          }
          break;
        case KeyCodes.KEY_ESCAPE:
          if (escapeDisabled_) break;
          if (cancelButton_ == null) {
            if ((okButton_ != null) && okButton_.isEnabled()) {
              nativeEvent.preventDefault();
              nativeEvent.stopPropagation();
              event.cancel();
              okButton_.click();
            }
          } else if (cancelButton_.isEnabled()) {
            nativeEvent.preventDefault();
            nativeEvent.stopPropagation();
            event.cancel();
            cancelButton_.click();
          }
          break;
      }
    }
  }
Example #2
0
 protected void addButton(ThemedButton button) {
   button.addStyleDependentName("DialogAction");
   buttonPanel_.add(button);
   allButtons_.add(button);
 }