Package com.google.gwt.user.client

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


      for (int i = 0; i < value.length(); i++) {

         int keyCode = value.charAt(i);

         // trigger keyDown and keyPress
         Event keyDownEvent = EventBuilder.create(Event.ONKEYDOWN).setKeyCode(keyCode).build();
         Event keyPressEvent = EventBuilder.create(Event.ONKEYPRESS).setKeyCode(keyCode).build();
         dispatchEventsInternal((IsWidget) hasTextWidget, check, keyDownEvent, keyPressEvent);

         // check if one on the events has been prevented
         boolean keyDownEventPreventDefault = JavaScriptObjects.getBoolean(keyDownEvent,
                  JsoProperties.EVENT_PREVENTDEFAULT);
         boolean keyPressEventPreventDefault = JavaScriptObjects.getBoolean(keyPressEvent,
                  JsoProperties.EVENT_PREVENTDEFAULT);

         if (!keyDownEventPreventDefault && !keyPressEventPreventDefault) {
            hasTextWidget.setText(value.substring(0, i + 1));
            changed = true;

            if (hasTextWidget instanceof ValueBoxBase) {
               JavaScriptObjects.setProperty(((Widget) hasTextWidget).getElement(),
                        JsoProperties.SELECTION_START, i + 1);
               JavaScriptObjects.setProperty(((Widget) hasTextWidget).getElement(),
                        JsoProperties.SELECTION_END, i + 1);
            }
         }

         // trigger keyUp
         Event keyUpEvent = EventBuilder.create(Event.ONKEYUP).setKeyCode(keyCode).build();
         dispatchEventsInternal((IsWidget) hasTextWidget, check, keyUpEvent);

      }

      if (blur) {
View Full Code Here


      if (widget == null) {
         return;
      }

      // trigger keyDown and keyPress
      Event keyDownEvent = EventBuilder.create(Event.ONKEYDOWN).setKeyCode(keyCode).build();
      Event keyPressEvent = EventBuilder.create(Event.ONKEYPRESS).setKeyCode(keyCode).build();
      dispatchEventsInternal(widget, true, keyDownEvent, keyPressEvent);

      // check if one on the events has been prevented
      boolean keyDownEventPreventDefault = JavaScriptObjects.getBoolean(keyDownEvent,
               JsoProperties.EVENT_PREVENTDEFAULT);
      boolean keyPressEventPreventDefault = JavaScriptObjects.getBoolean(keyPressEvent,
               JsoProperties.EVENT_PREVENTDEFAULT);

      if (!keyDownEventPreventDefault && !keyPressEventPreventDefault) {

         StringBuilder sb = new StringBuilder(widget.getText());

         // remove selectionRange
         int selectionStart = JavaScriptObjects.getInteger(widget.asWidget().getElement(),
                  JsoProperties.SELECTION_START);
         int selectionEnd = JavaScriptObjects.getInteger(widget.asWidget().getElement(),
                  JsoProperties.SELECTION_END);

         switch (keyCode) {
            case KeyCodes.KEY_ALT:
            case KeyCodes.KEY_CTRL:
            case KeyCodes.KEY_DELETE:
            case KeyCodes.KEY_DOWN:
            case KeyCodes.KEY_END:
            case KeyCodes.KEY_ENTER:
            case KeyCodes.KEY_ESCAPE:
            case KeyCodes.KEY_HOME:
            case KeyCodes.KEY_LEFT:
            case KeyCodes.KEY_PAGEDOWN:
            case KeyCodes.KEY_PAGEUP:
            case KeyCodes.KEY_RIGHT:
            case KeyCodes.KEY_SHIFT:
            case KeyCodes.KEY_UP:
               // nothing to do
               break;
            case KeyCodes.KEY_TAB:
               blur(widget);
               break;
            case KeyCodes.KEY_BACKSPACE:
               if (selectionStart == selectionEnd) {
                  sb.deleteCharAt(selectionStart);
               } else {
                  sb.replace(selectionStart, selectionEnd, "");
               }
               widget.setText(sb.toString());
               break;
            default:
               sb.replace(selectionStart, selectionEnd, "");

               sb.insert(selectionStart, (char) keyCode);

               selectionStart = selectionEnd = selectionStart + 1;

               widget.setText(sb.toString());

               JavaScriptObjects.setProperty(widget.asWidget().getElement(),
                        JsoProperties.SELECTION_START, selectionStart);
               JavaScriptObjects.setProperty(widget.asWidget().getElement(),
                        JsoProperties.SELECTION_END, selectionEnd);
         }

         // trigger keyUp
         Event keyUpEvent = EventBuilder.create(Event.ONKEYUP).setKeyCode(keyCode).build();
         dispatchEventsInternal(widget, true, keyUpEvent);
      }
   }
View Full Code Here

    */
   public static void removeText(HasText hasTextWidget, int backspacePressNumber) {
      boolean changed = false;

      for (int i = 0; i < backspacePressNumber; i++) {
         Event keyDownEvent = EventBuilder.create(Event.ONKEYDOWN).setKeyCode(
                  KeyCodes.KEY_BACKSPACE).build();
         Event keyUpEvent = EventBuilder.create(Event.ONKEYUP).setKeyCode(KeyCodes.KEY_BACKSPACE).build();
         dispatchEvent((IsWidget) hasTextWidget, keyDownEvent, keyUpEvent);

         boolean keyDownEventPreventDefault = JavaScriptObjects.getBoolean(keyDownEvent,
                  JsoProperties.EVENT_PREVENTDEFAULT);

View Full Code Here

      return true;
   }

   private static void clickInternal(IsWidget parent, UIObject target) {
      Event onMouseOver = EventBuilder.create(Event.ONMOUSEOVER).setTarget(target).build();
      Event onMouseDown = EventBuilder.create(Event.ONMOUSEDOWN).setTarget(target).setButton(
               Event.BUTTON_LEFT).build();
      Event onMouseUp = EventBuilder.create(Event.ONMOUSEUP).setTarget(target).setButton(
               Event.BUTTON_LEFT).build();
      Event onClick = EventBuilder.create(Event.ONCLICK).setTarget(target).build();

      dispatchEvent(parent, onMouseOver, onMouseDown, onMouseUp, onClick);
   }
View Full Code Here

   @PatchMethod
   static void buttonClick(Object domImpl, ButtonElement button) {

      EventTarget relatedTarget = button.cast();
      Event onMouseOver = EventBuilder.create(Event.ONMOUSEOVER).setTarget(button).setRelatedTarget(
               relatedTarget).build();
      dispatchEvent(domImpl, button, onMouseOver);

      Event onMouseDown = EventBuilder.create(Event.ONMOUSEDOWN).setTarget(button).setRelatedTarget(
               relatedTarget).setButton(Event.BUTTON_LEFT).build();
      dispatchEvent(domImpl, button, onMouseDown);

      Event onMouseUp = EventBuilder.create(Event.ONMOUSEUP).setTarget(button).setRelatedTarget(
               relatedTarget).setButton(Event.BUTTON_LEFT).build();
      dispatchEvent(domImpl, button, onMouseUp);

      Event onClick = EventBuilder.create(Event.ONCLICK).setTarget(button).setRelatedTarget(
               relatedTarget).build();
      dispatchEvent(domImpl, button, onClick);
   }
View Full Code Here

@PatchClass(target = "com.google.gwt.user.client.ui.Image$State")
class ImageStatePatcher {

   @PatchMethod
   static void fireSyntheticLoadEvent(Object state, Image image) {
      Event loadEvent = EventBuilder.create(Event.ONLOAD).build();
      Browser.dispatchEvent(image, loadEvent);
   }
View Full Code Here

      final StringBuilder sb = new StringBuilder();

      Event.addNativePreviewHandler(new NativePreviewHandler() {

         public void onPreviewNativeEvent(NativePreviewEvent event) {
            Event nativeEvent = Event.as(event.getNativeEvent());
            int eventType = DOM.eventGetType(nativeEvent);
            if (eventType == Event.ONCLICK) {
               sb.append("click!");
            }
         }
View Full Code Here

            assertEquals(4, event.getScreenY());
         }

      });

      Event clickEvent = EventBuilder.create(Event.ONCLICK).setMouseX(1).setMouseY(2).setMouseScreenX(
               3).setMouseScreenY(4).build();

      // Act
      Browser.dispatchEvent(b, clickEvent);
View Full Code Here

    grid.setCellSpacing(0);
    grid.setCellPadding(0);
    grid.addClickHandler(new ClickHandler() {

      public void onClick(ClickEvent event) {
        Event evt = DOM.eventGetCurrentEvent();
        ComponentEvent be = new ComponentEvent(DatePicker.this, evt);
        onDayClick(be);
      }
    });
    String s = GXT.isAriaEnabled() ? "<a role=gridcell tabindex=0><span role=presentation></span></a>"
View Full Code Here

  public boolean isAutoHideAllowEvent() {
    return autoHideAllowEvent;
  }

  public void onPreviewNativeEvent(NativePreviewEvent event) {
    Event e = event.getNativeEvent().<Event> cast();

    PreviewEvent pe = new PreviewEvent(this, event);
    pe.setType(new EventType(e.getTypeInt()));
    pe.setEvent(e);

    lastX = pe.getClientX();
    lastY = pe.getClientY();
View Full Code Here

TOP

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

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.