Пример #1
0
 @Override
 public void onKeyDown(KeyDownEvent event) {
   ignoreNextKeyPress = true;
   Event nativeEvent = (Event) event.getNativeEvent();
   if (!nativeEvent.isCancelled()) {
     handleRepeatableKey(nativeEvent);
   }
   cancelNextKeyPress = nativeEvent.isCancelled();
 }
Пример #2
0
 @Override
 public void onKeyUp(KeyUpEvent event) {
   ignoreNextKeyPress = false;
   cancelNextKeyPress = false;
   Event nativeEvent = (Event) event.getNativeEvent();
   if (!nativeEvent.isCancelled()) {
     handleKeyRelease(nativeEvent);
   }
 }
Пример #3
0
 @Override
 public void onKeyPress(KeyPressEvent event) {
   Event nativeEvent = (Event) event.getNativeEvent();
   if (!ignoreNextKeyPress) {
     if (!nativeEvent.isCancelled()) {
       handleRepeatableKey(nativeEvent);
     }
   } else if (cancelNextKeyPress) {
     nativeEvent.xPreventDefault();
   }
   ignoreNextKeyPress = false;
   cancelNextKeyPress = false;
 }
Пример #4
0
  /**
   * Called when a KeyDown event is triggered inside the rich text area.
   *
   * @param event the native event that was fired
   */
  protected void onKeyDown(Event event) {
    if (event == null || event.isCancelled()) {
      return;
    }

    switch (event.getKeyCode()) {
      case KeyCodes.KEY_DOWN:
        onDownArrow(event);
        break;
      case KeyCodes.KEY_UP:
        onUpArrow(event);
        break;
      default:
        break;
    }
  }
Пример #5
0
  /**
   * Called by the underlying rich text are when user actions trigger browser events, after all the
   * registered listeners have been notified.
   *
   * @param event the native event that was fired
   * @see RichTextArea#onBrowserEvent(com.google.gwt.user.client.Event)
   * @see RichTextArea#getCurrentEvent()
   */
  public void onBrowserEvent(Event event) {
    if (event == null || event.isCancelled()) {
      return;
    }

    switch (event.getTypeInt()) {
      case Event.ONKEYDOWN:
        onKeyDown(event);
        break;
      case Event.ONKEYPRESS:
        onKeyPress(event);
        break;
      case Event.ONLOAD:
        onLoad(event);
        break;
      default:
        break;
    }
  }
Пример #6
0
  @Override
  protected void onKeyDown(Event event) {
    if (event == null || event.isCancelled()) {
      return;
    }

    switch (event.getKeyCode()) {
      case KeyCodes.KEY_TAB:
        // IE moves the focus when Tab key is down and thus the key press event doesn't get fired.
        // If we block
        // the key down event then IE doesn't fire key press. We are forced to apply out custom
        // behavior for tab
        // key now, on key down, and not later, on key press.
        onTab(event);
        break;
      default:
        super.onKeyDown(event);
        break;
    }
  }