Package com.google.gwt.user.client

Examples of com.google.gwt.user.client.Event


    /**
     * Show the popup at the current mouse position.  Assumes a mouse event
     * is currently being processed.
     */
    protected void showPopup(AsyncCallback<Void> callback) {
        Event event = Event.getCurrentEvent();
        showPopup(callback, event.getClientX()+Window.getScrollLeft(), event.getClientY()+Window.getScrollTop());
    }
View Full Code Here


      protected void onPreviewNativeEvent( final NativePreviewEvent event ) {
        // Switch on the event type
        int type = event.getTypeInt();
        switch ( type ) {
          case Event.ONKEYDOWN: {
            Event nativeEvent = Event.as( event.getNativeEvent() );
            if ( (char) nativeEvent.getKeyCode() == KeyCodes.KEY_ESCAPE ) {
              event.cancel();
              hide();
            }
            return;
          }
View Full Code Here

    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();
    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;
        }
View Full Code Here

            }

            if (features.length() > 0) {
                // if 'special features' are set, use window.open(), unless
                // a modifier key is held (ctrl to open in new tab etc)
                Event e = DOM.eventGetCurrentEvent();
                if (!e.getCtrlKey() && !e.getAltKey() && !e.getShiftKey()
                        && !e.getMetaKey()) {
                    Window.open(src, target, features);
                    e.preventDefault();
                }
            }
        }
    }
View Full Code Here

    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();
    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:
        // 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: {
        // 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;
        }
View Full Code Here

  public void testOnBrowserEvent() {
    CustomCell cell = new CustomCell();
    CellWidget<String> cw = new CellWidget<String>(cell, "test");
    assertEquals("test", cw.getValue());

    Event event = Document.get().createChangeEvent().cast();
    cw.onBrowserEvent(event);
    cell.assertLastEventKey("test");
    cell.assertLastEventValue("test");
    assertEquals("newValue", cw.getValue());
  }
View Full Code Here

    CustomCell cell = new CustomCell();
    final CellWidget<String> cw = new CellWidget<String>(cell, "test", keyProvider);
    assertEquals("test", cw.getValue());
    assertEquals(keyProvider, cw.getKeyProvider());

    Event event = Document.get().createChangeEvent().cast();
    cw.onBrowserEvent(event);
    cell.assertLastEventKey("t");
    cell.assertLastEventValue("test");
    assertEquals("newValue", cw.getValue());
  }
View Full Code Here

    // Add a ValueChangeHandler.
    MockValueChangeHandler<String> handler = new MockValueChangeHandler<String>();
    cw.addValueChangeHandler(handler);

    // Fire an native event that will trigger a value change event.
    Event event = Document.get().createChangeEvent().cast();
    cw.onBrowserEvent(event);
    cell.assertLastEventKey("test");
    cell.assertLastEventValue("test");
    handler.assertLastValue("newValue");
    assertEquals("newValue", cw.getValue());
View Full Code Here

      // Fire a change event on the input element if the value changed.
      maybeFireChangeEvent(widget);
      focusedInput = null;

      // The blur event has already fired, so we need to synthesize one.
      Event blurEvent = Document.get().createFocusEvent().cast();
      dispatchCellEvent(widget, target, Event.ONBLUR, null);
    } else if (BrowserEvents.LOAD.equals(type) || BrowserEvents.ERROR.equals(type)) {
      DOM.dispatchEvent(event, widget.getElement(), listener);
    }
  }
View Full Code Here

      // Save the new value in case it changes again.
      focusedInputValue = newValue;

      // Fire a synthetic event to the input element.
      Element target = focusedInput;
      Event changeEvent = Document.get().createChangeEvent().cast();
      dispatchCellEvent(widget, target, Event.ONCHANGE, changeEvent);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.Event

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.