Package com.google.gwt.dom.client

Examples of com.google.gwt.dom.client.NativeEvent


      return table;
    }

    @Override
    public void onCellPreview(CellPreviewEvent<T> event) {
      NativeEvent nativeEvent = event.getNativeEvent();
      String eventType = event.getNativeEvent().getType();
      if (BrowserEvents.KEYDOWN.equals(eventType) && !event.isCellEditing()) {
        /*
         * Handle keyboard navigation, unless the cell is being edited. If the
         * cell is being edited, we do not want to change rows.
         *
         * Prevent default on navigation events to prevent default scrollbar
         * behavior.
         */
        int oldRow = table.getKeyboardSelectedRow();
        int oldColumn = table.getKeyboardSelectedColumn();
        boolean isRtl = LocaleInfo.getCurrentLocale().isRTL();
        int keyCodeLineEnd = isRtl ? KeyCodes.KEY_LEFT : KeyCodes.KEY_RIGHT;
        int keyCodeLineStart = isRtl ? KeyCodes.KEY_RIGHT : KeyCodes.KEY_LEFT;
        int keyCode = nativeEvent.getKeyCode();
        if (keyCode == keyCodeLineEnd) {
          int nextColumn = findInteractiveColumn(oldColumn, false);
          if (nextColumn <= oldColumn) {
            // Wrap to the next row.
            table.setKeyboardSelectedRow(oldRow + 1);
View Full Code Here


   * @param y the y coordinate
   * @return a mock {@link TouchStartEvent}
   */
  private static TouchEvent<?> createTouchStartEvent(int x, int y) {
    CustomTouchEvent event = new CustomTouchEvent();
    NativeEvent nativeEvent = createNativeTouchEvent();
    nativeEvent.getTouches().push(createTouch(x, y));
    event.setNativeEvent(nativeEvent);
    return event;
  }
View Full Code Here

   * @param action the action to handle
   * @param selectionModel the {@link SelectionModel} to update
   */
  protected void handleMultiSelectionEvent(CellPreviewEvent<T> event,
      SelectAction action, MultiSelectionModel<? super T> selectionModel) {
    NativeEvent nativeEvent = event.getNativeEvent();
    String type = nativeEvent.getType();
    if (BrowserEvents.CLICK.equals(type)) {
      /*
       * Update selection on click. Selection is toggled only if the user
       * presses the ctrl key. If the user does not press the control key,
       * selection is additive.
       */
      boolean shift = nativeEvent.getShiftKey();
      boolean ctrlOrMeta = nativeEvent.getCtrlKey() || nativeEvent.getMetaKey();
      boolean clearOthers = (translator == null) ? !ctrlOrMeta
          : translator.clearCurrentSelection(event);
      if (action == null || action == SelectAction.DEFAULT) {
        action = ctrlOrMeta ? SelectAction.TOGGLE : SelectAction.SELECT;
      }
      doMultiSelection(selectionModel, event.getDisplay(), event.getIndex(),
          event.getValue(), action, shift, clearOthers);
    } else if (BrowserEvents.KEYUP.equals(type)) {
      int keyCode = nativeEvent.getKeyCode();
      if (keyCode == 32) {
        /*
         * Update selection when the space bar is pressed. The spacebar always
         * toggles selection, regardless of whether the control key is pressed.
         */
        boolean shift = nativeEvent.getShiftKey();
        boolean clearOthers = (translator == null) ? false
            : translator.clearCurrentSelection(event);
        if (action == null || action == SelectAction.DEFAULT) {
          action = SelectAction.TOGGLE;
        }
View Full Code Here

          return;
      }
    }

    // Handle default selection.
    NativeEvent nativeEvent = event.getNativeEvent();
    String type = nativeEvent.getType();
    if (BrowserEvents.CLICK.equals(type)) {
      if (nativeEvent.getCtrlKey() || nativeEvent.getMetaKey()) {
        // Toggle selection on ctrl+click.
        selectionModel.setSelected(value, !selectionModel.isSelected(value));
      } else {
        // Select on click.
        selectionModel.setSelected(value, true);
      }
    } else if (BrowserEvents.KEYUP.equals(type)) {
      // Toggle selection on space.
      int keyCode = nativeEvent.getKeyCode();
      if (keyCode == 32) {
        selectionModel.setSelected(value, !selectionModel.isSelected(value));
      }
    }
  }
View Full Code Here

      return false;
    }

    public SelectAction translateSelectionEvent(CellPreviewEvent<T> event) {
      // Handle the event.
      NativeEvent nativeEvent = event.getNativeEvent();
      if (BrowserEvents.CLICK.equals(nativeEvent.getType())) {
        // Ignore if the event didn't occur in the correct column.
        if (column > -1 && column != event.getColumn()) {
          return SelectAction.IGNORE;
        }

        // Determine if we clicked on a checkbox.
        Element target = nativeEvent.getEventTarget().cast();
        if ("input".equals(StringCase.toLower(target.getTagName()))) {
          final InputElement input = target.cast();
          if ("checkbox".equals(StringCase.toLower(input.getType()))) {
            // Synchronize the checkbox with the current selection state.
            input.setChecked(event.getDisplay().getSelectionModel().isSelected(
View Full Code Here

        passTest(event.getNativeEvent());
      }
    });
    button.addMouseOutHandler(new MouseOutHandler() {
      public void onMouseOut(MouseOutEvent event) {
        NativeEvent nativeEvent = event.getNativeEvent();
        assert nativeEvent.getRelatedEventTarget() != null;
        assert nativeEvent.getEventTarget() != null;
        if (button.getElement().equals(nativeEvent.getEventTarget())
            && button.getElement().getParentElement().equals(
                nativeEvent.getRelatedEventTarget())) {
          passTest(nativeEvent);
        }
      }
    });
    button.addMouseOverHandler(new MouseOverHandler() {
      public void onMouseOver(MouseOverEvent event) {
        NativeEvent nativeEvent = event.getNativeEvent();
        assert nativeEvent.getRelatedEventTarget() != null;
        assert nativeEvent.getEventTarget() != null;
        if (button.getElement().equals(nativeEvent.getEventTarget())
            && button.getElement().getParentElement().equals(
                nativeEvent.getRelatedEventTarget())) {
          passTest(nativeEvent);
        }
      }
    });
  }
View Full Code Here

    // Keep the crosshair under the cursor
    Event.addNativePreviewHandler(new NativePreviewHandler() {
      public void onPreviewNativeEvent(NativePreviewEvent event) {
        // Ignore events outside of the sandbox
        NativeEvent nativeEvent = event.getNativeEvent();
        Element target = Element.as(nativeEvent.getEventTarget());
        if (!sandbox.getElement().isOrHasChild(target)
            && !positioner.getElement().isOrHasChild(target)) {
          positioner.removeFromParent();
          return;
        }
               
        switch (Event.as(nativeEvent).getTypeInt()) {
          case Event.ONMOUSEMOVE:
            int absX = nativeEvent.getClientX() + Window.getScrollLeft();
            int absY = nativeEvent.getClientY() + Window.getScrollTop();
            RootPanel.get().add(positioner, absX, absY);

            echo.setHTML("event.clientX: " + nativeEvent.getClientX() + "<br>"
                + "event.clientY: " + nativeEvent.getClientY() + "<br>"
                + "absolute left: " + positioner.getAbsoluteLeft() + "<br>"
                + "absolute top: " + positioner.getAbsoluteTop());
            break;
        }
      }
View Full Code Here

    // synchronous, so we simply set and clear the flag within this method.
    allowClick = true;

    // Mouse coordinates are not always available (e.g., when the click is
    // caused by a keyboard event).
    NativeEvent evt = Document.get().createClickEvent(1, 0, 0, 0, 0, false,
        false, false, false);
    getElement().dispatchEvent(evt);

    allowClick = false;
  }
View Full Code Here

  @Override
  protected void onPreviewNativeEvent(NativePreviewEvent event) {
    // We need to preventDefault() on mouseDown events (outside of the
    // DialogBox content) to keep text from being selected when it
    // is dragged.
    NativeEvent nativeEvent = event.getNativeEvent();

    if (!event.isCanceled()
        && (event.getTypeInt() == Event.ONMOUSEDOWN)
        && isCaptionEvent(nativeEvent)) {
      nativeEvent.preventDefault();
    }

    super.onPreviewNativeEvent(event);
  }
View Full Code Here

    //Doesn't really work as firefox starts f'ing with the tool bar

    // Define an inner class to handle the event
    Event.addNativePreviewHandler(new NativePreviewHandler() {
      public void onPreviewNativeEvent(NativePreviewEvent preview) {
        NativeEvent event = preview.getNativeEvent();

        if (event.getCtrlKey()) {
          int charCode = event.getCharCode();
          if (charCode == 45) { //-

            //mZoomOutButton.click();
            preview.consume();
          } else if (charCode == 43 // +
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.NativeEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.