コード例 #1
0
ファイル: VWindow.java プロジェクト: JamesLefeu/vaadin
 @Override
 public void onKeyDown(KeyDownEvent event) {
   if (shortcutHandler != null) {
     shortcutHandler.handleKeyboardEvent(Event.as(event.getNativeEvent()));
     return;
   }
 }
コード例 #2
0
ファイル: CmsDateBox.java プロジェクト: rinnes/opencms-core
  /**
   * Blurs the time box if the user clicks outside of it.
   *
   * <p>
   *
   * @param event the native preview event
   */
  protected void previewNativeEvent(NativePreviewEvent event) {

    Event nativeEvent = Event.as(event.getNativeEvent());
    if ((nativeEvent.getTypeInt() == Event.ONCLICK)) {
      EventTarget target = nativeEvent.getEventTarget();
      if (!Element.is(target)) {
        return;
      }
      Element element = Element.as(target);
      if (!m_time.getElement().isOrHasChild(element)) {
        m_time.blur();
      }
    }
  }
コード例 #3
0
ファイル: DownloadTemplateCell.java プロジェクト: cyverse/DE
  @Override
  public void onBrowserEvent(
      Cell.Context context,
      Element parent,
      MetadataTemplateInfo value,
      NativeEvent event,
      ValueUpdater<MetadataTemplateInfo> valueUpdater) {
    if (value == null) {
      return;
    }

    Element eventTarget = Element.as(event.getEventTarget());
    Element child = findAppNameElement(parent);
    if (child != null && child.isOrHasChild(eventTarget)) {
      switch (Event.as(event).getTypeInt()) {
        case Event.ONCLICK:
          doOnClick(eventTarget, value);
          break;
        default:
          break;
      }
    }
  }
コード例 #4
0
ファイル: GalleryPanel.java プロジェクト: ssinica/ssgallery
  /** {@code ClickHandler} */
  @Override
  public void onClick(ClickEvent event) {
    NativeEvent nativeEvent = event.getNativeEvent();
    Element element = DOM.eventGetTarget(Event.as(nativeEvent));
    element =
        GWTUtils.getElementWithAttr((com.google.gwt.user.client.Element) element.cast(), "uid");
    Element dataQueryEl = null;
    if (element != null) {
      dataQueryEl =
          GWTUtils.findDataQueryElement((com.google.gwt.user.client.Element) element.cast());
      String uid = element.getAttribute("uid");
      String json = dataQueryEl.getAttribute("data-query");

      if (!GWTUtils.isEmpty(uid)) {
        JSONObject targetJson = null;
        if (!GWTUtils.isEmpty(json)) {
          targetJson = (JSONObject) JSONParser.parse(json);
        }
        processClickEvent(uid, targetJson);
      }
    } else {
      return;
    }
  }
コード例 #5
0
 protected void onPreviewNativeEvent(NativePreviewEvent event) {
   // Cancel the event based on the deprecated onEventPreview() method
   if (event.isFirstHandler() && !onEventPreview(Event.as(event.getNativeEvent()))) {
     event.cancel();
   }
 }
コード例 #6
0
  /**
   * Preview the {@link NativePreviewEvent}.
   *
   * @param event the {@link NativePreviewEvent}
   */
  private void previewNativeEvent(NativePreviewEvent event) {
    // If the event has been canceled or consumed, ignore it
    if (event.isCanceled() || (!previewAllNativeEvents && event.isConsumed())) {
      // We need to ensure that we cancel the event even if its been consumed so
      // that popups lower on the stack do not auto hide
      if (modal) {
        event.cancel();
      }
      return;
    }

    // Fire the event hook and return if the event is canceled
    onPreviewNativeEvent(event);
    if (event.isCanceled()) {
      return;
    }

    // If the event targets the popup or the partner, consume it
    Event nativeEvent = Event.as(event.getNativeEvent());
    boolean eventTargetsPopupOrPartner =
        eventTargetsPopup(nativeEvent) || eventTargetsPartner(nativeEvent);
    if (eventTargetsPopupOrPartner) {
      event.consume();
    }

    // Cancel the event if it doesn't target the modal popup. Note that the
    // event can be both canceled and consumed.
    if (modal) {
      event.cancel();
    }

    // Switch on the event type
    int type = nativeEvent.getTypeInt();

    if ((type & Event.TOUCHEVENTS) != 0) { // it is a touch event
      CancelEventTimer.touchEventOccured();
    }

    if ((type & Event.MOUSEEVENTS) != 0) {
      if (CancelEventTimer.cancelMouseEvent()) {
        return;
      }
    }

    switch (type) {
      case Event.ONKEYDOWN:
        {
          if (!onKeyDownPreview(
              (char) nativeEvent.getKeyCode(),
              KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
            event.cancel();
          }
          return;
        }
      case Event.ONKEYUP:
        {
          if (!onKeyUpPreview(
              (char) nativeEvent.getKeyCode(),
              KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
            event.cancel();
          }
          return;
        }
      case Event.ONKEYPRESS:
        {
          if (!onKeyPressPreview(
              (char) nativeEvent.getKeyCode(),
              KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
            event.cancel();
          }
          return;
        }

      case Event.ONMOUSEDOWN:
      case Event.ONTOUCHSTART:
        // Don't eat events if event capture is enabled, as this can
        // interfere with dialog dragging, for example.
        if (DOM.getCaptureElement() != null) {
          event.consume();
          return;
        }

        if (!eventTargetsPopupOrPartner && autoHide) {
          hide(true);
          return;
        }
        break;
      case Event.ONMOUSEUP:
      case Event.ONMOUSEMOVE:
      case Event.ONCLICK:
      case Event.ONDBLCLICK:
      case Event.ONTOUCHEND:
        {
          // Don't eat events if event capture is enabled, as this can
          // interfere with dialog dragging, for example.
          if (DOM.getCaptureElement() != null) {
            event.consume();
            return;
          }
          break;
        }

      case Event.ONFOCUS:
        {
          Element target = nativeEvent.getTarget();
          if (modal && !eventTargetsPopupOrPartner && (target != null)) {
            blur(target);
            event.cancel();
            return;
          }
          break;
        }
    }
  }